2019 ICPC Asia Taipei Hsinchu Regional
A. Rush Hour Puzzle
B. The Power Monitor System
C. Are They All Integers?
#include <bits/stdc++.h> using namespace std; int n, a[110]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) if (i != j && i != k && j != k && abs(a[i] - a[j]) % a[k]) return printf("no"), 0; printf("yes"); return 0; }
D. Tapioka
#include <bits/stdc++.h> using namespace std; bool f; int main() { string s; while (cin >> s) { if (s != "bubble" && s != "tapioka") cout << s << " ", f = 1; } if (!f) cout << "nothing"; return 0; }
E. The League of Sequence Designers
#include <bits/stdc++.h> using namespace std; int main() { int cass, k, l; for (cin >> cass; cass; cass--) { cin >> k >> l; if (l >= 2000) { puts("-1"); continue; } cout << 1999 << endl << -1 << " "; for (int i = 2; i <= 1998; i++) cout << 1 + (k / 1997) << " "; cout << 2 + (k - (k / 1997) * 1997) << endl; } return 0; }
F. Miss Sloane
G. Optimal Selection
H. Mining a
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll n, cass; for (cin >> cass; cass; cass--) { cin >> n; cout << ((n * (n + 1)) ^ (n + 1)) << endl; } return 0; }
I. The Spectrum
J. Automatic Control Machine
#include <bits/stdc++.h> using namespace std; bitset<510> num[30]; char s[1010]; int main() { int cass; for (scanf("%d", &cass); cass; cass--) { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%s", s); num[i] = bitset<510>(s); } int len = 1 << m, ans = m + 1; for (int i = 1; i < len; i++) { int t = i, cnt = 0; bitset<510> now(0); for (int j = 0; j < m && t; j++, t >>= 1) if (t & 1) now = now | num[j], cnt++; if (now.count() == n) ans = min(ans, cnt); } printf("%d\n", ans == m + 1 ? -1 : ans); } return 0; }
K. Length of Bundle Rope
#include <bits/stdc++.h> using namespace std; priority_queue<int, vector<int>, greater<int> > q; int main() { int n, cass; for (scanf("%d", &cass); cass; cass--) { while (!q.empty()) q.pop(); scanf("%d", &n); for (int i = 0, x; i < n; i++) scanf("%d", &x), q.push(x); int ans = 0; while (q.size() > 1) { int x = q.top(); q.pop(); x += q.top(); q.pop(); ans += x, q.push(x); } printf("%d\n", ans); } return 0; }

浙公网安备 33010602011771号