#include<cstdio> #include<algorithm> #include<iostream> #include<vector> #include<map> #include<queue> #include<set> #include<ctime> #include<cstring> #include<cstdlib> #include<math.h> usingnamespacestd; //typedef long long ll; #define int long long constint N = 1e3 + 5; constint maxn = 2e6 + 20; constint mod = 1e9 + 7; int inv[maxn], dp[maxn], vis[maxn], dis[maxn]; int fac[maxn]; vector<int> vec; typedef pair<int, int> p; intmax(int a, int b){ return a > b ? a : b; } intmin(int a, int b){ return a < b ? a : b; } intgcd(int a, int b){ return b ? gcd(b, a % b) : a; } intlcm(int a, int b){ return a * b / gcd(a, b); } voidinit() { fac[0] = 1; for (int i = 1; i <= 20; i++) fac[i] = fac[i - 1] * i; } signedmain() { ios::sync_with_stdio(false); cin.tie(0); int q, u, v, w, k, t; cin>>t; while(t--) { int a,b; cin>>a; cout<<1ll<<' '<<a-1ll<<endl; } }
#include<cstdio> #include<algorithm> #include<iostream> #include<vector> #include<map> #include<queue> #include<set> #include<ctime> #include<cstring> #include<cstdlib> #include<math.h> usingnamespacestd; //typedef long long ll; #define int long long constint N = 1e3 + 5; constint maxn = 2e6 + 20; constint mod = 1e9 + 7; int inv[maxn], dp[maxn], vis[maxn], dis[maxn]; int fac[maxn]; vector<int> vec; typedef pair<int, int> p; intmax(int a, int b){ return a > b ? a : b; } intmin(int a, int b){ return a < b ? a : b; } intgcd(int a, int b){ return b ? gcd(b, a % b) : a; } intlcm(int a, int b){ return a * b / gcd(a, b); } voidinit() { fac[0] = 1; for (int i = 1; i <= 20; i++) fac[i] = fac[i - 1] * i; } map<int, int> mp; signedmain() { ios::sync_with_stdio(false); cin.tie(0); int q, u, v, w, k, t; cin >> t; while (t--) { mp.clear(); int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> v; if (!mp[v]) ans++, mp[v] = 1; } cout << ans << endl; } }
#include<cstdio> #include<algorithm> #include<iostream> #include<vector> #include<map> #include<queue> #include<set> #include<ctime> #include<cstring> #include<cstdlib> #include<math.h> usingnamespacestd; //typedef long long ll; #define int long long constint N = 1e3 + 5; constint maxn = 2e6 + 20; constint mod = 1e9 + 7; int inv[maxn], dp[maxn], vis[maxn], dis[maxn]; int fac[maxn]; vector<int> vec; typedef pair<int, int> p; intmax(int a, int b){ return a > b ? a : b; } intmin(int a, int b){ return a < b ? a : b; } intgcd(int a, int b){ return b ? gcd(b, a % b) : a; } intlcm(int a, int b){ return a * b / gcd(a, b); } voidinit() { fac[0] = 1; for (int i = 1; i <= 20; i++) fac[i] = fac[i - 1] * i; } map<int, int> mp; signedmain() { ios::sync_with_stdio(false); cin.tie(0); int q, u, v, w, k, t; // cin >> t; // while (t--) // { int n; q = 0; cin >> n;
vector<int> a(n + 1, 0); vector<int> pb(n + 1, 0); vector<int> ans(n + 1, 0); for (int i = 0; i <= n - 2; i++) cin >> u >> v, a[u]++, a[v]++, pb[v] = pb[u]=i; if (n == 2) { cout << 0 << endl; return0; } for (int i = 1; i <= n; i++) {
if (a[i] == 1) ans[pb[i]] = ++q; if (q == 3) break; } for (int i = 0; i < n - 1; i++) { if (ans[i]) cout << ans[i] - 1 << endl; else cout << (++q - 1) << endl; }
#include<cstdio> #include<algorithm> #include<iostream> #include<vector> #include<map> #include<queue> #include<set> #include<ctime> #include<cstring> #include<cstdlib> #include<math.h> usingnamespacestd; //typedef long long ll; #define int long long constint N = 1e3 + 5; constint maxn = 2e6 + 20; constint mod = 1e9 + 7; int inv[maxn], dp[maxn], vis[maxn], dis[maxn]; int fac[maxn]; vector<int> vec; typedef pair<int, int> p; intmax(int a, int b){ return a > b ? a : b; } intmin(int a, int b){ return a < b ? a : b; } intgcd(int a, int b){ return b ? gcd(b, a % b) : a; } intlcm(int a, int b){ return a * b / gcd(a, b); } intksm(int a, int b) { int ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b >>= 1; } return ans; } map<int, int> mp; int a[66], b[66]; signedmain() { ios::sync_with_stdio(false); cin.tie(0); int q, u, v, w, k, t; // cin >> t; // while (t--) // { cin >> u >> v; if (u > v) { cout << -1 << endl; return0; } if (u == v) { if (u != 0) { cout << 1 << endl; cout << u << endl; } else cout << 0 << endl; return0; } int x = (v - u) / 2, y = (v + u) / 2; if ((x ^ y) == u && (x + y == v)) { cout << 2 << endl; cout << x << ' ' << y << endl; } else { if ((v - u) % 2 == 0) { cout << 3 << endl; cout << u << ' ' << (v - u) / 2 << ' ' << (v - u) / 2 << endl; } else cout << -1 << endl; } //} }