Memsql start[c]up 2.0-round 2-online Round
Topic links
I have to say this really hard to beat Ah ...
A: The golden section of the binary number, satisfies a property, for the bit I x i = xi? 1 + xi? 2 , so you can push all the bits to the first two to compare the size, but only this directly to make decisive explosion longlong Infinite WA8, finally found in the process of pushing, there is a difference above 1, you can directly judge the
B: Had to spit a notch mozie English, Today's Ying Yu is very hao, the topic looked very very long, can not be more amused. Actually understand is quite simple, as long as the greedy consider a into B and B into a case, and then determine whether to copy or move well
C: Three points, set F (x) for other people votes are less than X, their votes are greater than or equal to the cost of x, so it is easy to prove that f (x) is a concave single-peak function, you can use the three-point method to solve the
Code:
A:
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm>using namespace std; Const DOUBLE EPS = 1e-10;const int N = 100005;char A[n], B[n];long long a[n], B[n];int main () {scanf ("%s%s", A, B); int an = strlen (A); int bn = strlen (B); for (int i = 0; i < A; i++) a[i] = a[an-i-1]-' 0 '; for (int i = 0; I < bn; i++) b[i] = b[bn-i-1]-' 0 '; int n = max (an, BN); for (int i = n-1; I >= 2; i--) {if (A[i] >= b[i]) {a[i]-= b[i]; B[i] = 0;} else if (A[i] <= b[i]) {b[i]-= a[i]; A[i] = 0;} if (A[i] >= 2) {printf (">\n"); return 0;} if (B[i] >= 2) {printf ("<\n"); return 0;} A[i-1] + = A[i]; A[i-2] + = a[i];b[i-1] + = B[i]; B[i-2] + = B[i]; } long Long AA = a[0], BB = a[1]; Long Long cc = b[0], DD = b[1]; Long long x = 2 * (AA-CC)-(DD-BB); Long Long y = (DD-BB); if (x < 0 && y > 0) {printf ("<\n"); } else if (x > 0 && Y < 0) {printf (">\n"); } else if (x >= 0 && y >= 0) {x = x * x;y = y * y * 5;if (x = = y) printf ("=\n"); else if (x < y) printf ("<\n"); else printf (">\n"); } else {x = x * x;y = y * y * 5;if (x = = y) printf ("=\n"), else if (x < y) printf (">\n"), Else printf ("<\n"); } return 0;}
B:
#include <cstdio> #include <cstring> #include <algorithm>using namespace std;typedef unsigned long Long Ll;const int N = 100005;ll A[n], b[n], Suma, Sumb, N, M;int main () { scanf ("%llu%llu", &n, &m); for (int i = 0; i < n; i++) {scanf ("%llu", &a[i]); Suma + = A[i]; } for (int i = 0; i < m; i++) {scanf ("%llu", &b[i]); Sumb + = B[i]; } Sort (A, a + N); Sort (b, B + m); ll ans = 10000000000000000000ULL; ll sum = 0; for (ll i = 0; i < n-1; i++) {if (Sumb <= a[i]) { sum + = (n-i) * SUMB; ans = min (ans, sum); break;} Sum + = A[i]; } ans = min (ans, sum + sumb); sum = 0; for (ll i = 0; i < m-1; i++) {if (Suma <= b[i]) { sum + = (m-i) * suma; ans = min (ans, sum);} Sum + = B[i]; } ans = min (ans, sum + suma); printf ("%llu\n", ans); return 0;}
C:
#include <cstdio> #include <cstring> #include <vector> #include <algorithm>using namespace std; const int INF = 0x3f3f3f3f;const int N = 100005;int N, save[n];vector<int> g[n];int cal (int x) {int ans = 0, hav E = G[0].size (), sn = 0; for (int i = 1, i <= 100000; i++) {int J = 0;if (x <= g[i].size ()) {for (; J < G[i].size ()-X + 1; j + +) {ans + = g[i][j];have++; }}for (; J < G[i].size (); j + +) save[sn++] = G[i][j]; } sort (save, save + sn); for (int i = 0; i < x-have; i++) ans + = save[i]; return ans;} int main () {scanf ("%d", &n); int A, B; for (int i = 0; i < n; i++) {scanf ("%d%d", &a, &b); G[a].push_back (b); } for (int i = 1; I <= 100000; i++) sort (G[i].begin (), G[i].end ()); int L = 1, r = N; while (L < r-2) {int MIDL = (L * 2 + R)/3;int Midr = (L + R * 2)/3;if (CAL (MIDL) > Cal (MIDR)) L = Midl;else R = Midr; } int ans = INF; for (int i = l; I <= R; i++) ans = mIn (ANS, cal (i)); printf ("%d\n", ans); return 0;}