A. Stickogon
思路:
Code:
#include<bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; map <int, int> mp; for (int i = 1, x; i <= n; i++) { cin >> x; mp[x] ++; } int ans = 0; for (const pair <int, int> &i : mp) { ans += i.second / 3; } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) { solve(); } return 0; }
B. A BIT of a Construction
Code:
#include<bits/stdc++.h> using namespace std; void solve() { int n, k, x = 1; cin >> n >> k; if (n == 1) { cout << k << '\n'; return ; } while ((x << 1 | 1) < k) { x = x << 1 | 1; } cout << x << ' ' << k - x << ' '; for (int i = 3; i <= n; i++) cout << 0 << ' '; cout << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) { solve(); } return 0; }
标签:CodeCraft,cout,23,int,solve,补题,mp From: https://www.cnblogs.com/youhualiuh/p/18151267