usingnamespace std; constint N = 1e6 + 5; int d[N];
voidsolve(){ int n, ans = 0; scanf ("%d", &n); if (n == 1) { printf ("1\n"); return ; } for (int i = 1; i <= n; i++) d[i] = 0; for (int i = 1; i < n; i++) { int u, v; scanf ("%d%d", &u, &v); d[u] ++, d[v] ++; } for (int i = 1; i <= n; i++) { if (d[i] == 1) ans ++; } printf ("%d\n", ans); }
intmain(){ int t; scanf ("%d", &t); while (t --) { solve (); } }
intmain(){ ios::sync_with_stdio (0);cin.tie (0);cout.tie(0); cin >> x >> y; for (int a = 1; a <= 10000 ; a++) { int sum = (x+1)*(x-2)/2, A = x*(a-x+2); int fz = a*y - A - sum, fm = a - A - sum;
if (fz * fm <= 0 || a + 3 - x <= 1) continue; fz = abs (fz), fm = abs (fm); int dx = __gcd (fz, fm); fz /= dx, fm /= dx; if (fz > 10000 || fm > 10000) continue; //important
//cout << "a=" << a << endl; cout << fz << ' ' << fm << endl; for (int i = 0; i <= x - 3; i++) cout << "1 " << a - i << endl; cout << "1 1\n"; break; } }