/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; int a[8005]; bool vis[8005]; intmain(){ int kase; cin >> kase; while (kase--) { memset(vis, 0, sizeof(vis)); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1, _; i <= n; ++i) { _ = a[i]; for (int j = i + 1; j <= n; ++j) { _ += a[j]; if (_ > 8000) break; vis[_] = 1; } } int cnt = 0; for (int i = 1; i <= n; ++i) cnt += vis[a[i]]; cout << cnt << endl; } return0; }
/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; intmain(){ int kase; cin >> kase; while (kase--) { int n0, n1, n2; cin >> n0 >> n1 >> n2; string str; if (n0) { str.append(string(n0 + 1, '0')); if (n1) { str.push_back('1'); --n1; if (n1 % 2 == 0) { for (int i = 0; i < n1; i += 2) str.append("01"); if (n2) str.append(n2, '1'); } else { for (int i = 2; i < n1; i += 2) str.append("01"); if (n2) str.append(n2, '1'); str.push_back('0'); } } } elseif (n1) { if (n2) { str = string(n2 + 1, '1'); if (n1 % 2) { str.push_back('0'); --n1; for (int i = 0; i < n1; i += 2) str.append("10"); } else { for (int i = 0; i < n1; i += 2) str.append("01"); } } elseif (n1 % 2) { for (int i = 0; i < n1; i += 2) str.append("10"); } else { for (int i = 0; i < n1; i += 2) str.append("01"); str.push_back('0'); } } elseif (n2) str = string(n2 + 1, '1'); cout << str << endl; } return0; }
/* * @Author: Tifa * @Description: From <https://github.com/Tiphereth-A/CP-archives> * !!! ATTENEION: All the context below is licensed under a * GNU Affero General Public License, Version 3. * See <https://www.gnu.org/licenses/agpl-3.0.txt>. */ #include<bits/stdc++.h> usingnamespace std; intmain(){ int kase; cin >> kase; while (kase--) { int n; cin >> n; if (n < 4) { cout << -1 << endl; continue; } if (n % 2) { for (int i = n; i >= 1; i -= 2) cout << i << " "; cout << "4 2 "; for (int i = 6; i < n; i += 2) cout << i << " "; cout << endl; } else { for (int i = n - 1; i >= 1; i -= 2) cout << i << " "; cout << "4 2 "; for (int i = 6; i <= n; i += 2) cout << i << " "; cout << endl; } } return0; }