We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51ac2d3 commit 15ec0b6Copy full SHA for 15ec0b6
Contests/Cook Off/029 December 2012/Programs/Root of the Problem.cpp
@@ -0,0 +1,32 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+void solve()
5
+{
6
+ int no_of_vertices;
7
+ cin >> no_of_vertices;
8
9
+ int parent_id_sum = 0, child_id_sum = 0;
10
+ for(int i = 1; i <= no_of_vertices; i++)
11
+ {
12
+ int parent, child_sum;
13
+ cin >> parent >> child_sum;
14
15
+ parent_id_sum += parent;
16
+ child_id_sum += child_sum;
17
+ }
18
19
+ int root = parent_id_sum - child_id_sum;
20
+ cout << root << "\n";
21
+}
22
23
+int main()
24
25
+ int no_of_test_cases;
26
+ cin >> no_of_test_cases;
27
28
+ while(no_of_test_cases--)
29
+ solve();
30
31
+ return 0;
32
0 commit comments