ACM-ICPC Asia Training League 暑假第一阶段第四场 ABCDH
模拟这个
1 #include <bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 const int N = 5e6+10; 5 int t, q, p, m, n; 6 unsigned int sa, sb, sc; 7 ll a[N], st[N], top; 8 ll MAX[N]; 9 unsigned int f() { 10 sa ^= sa<<16; 11 sa ^= sa >> 5; 12 sa ^= sa << 1; 13 unsigned int t = sa; 14 sa = sb; 15 sb = sc; 16 sc ^= t^sa; 17 return sc; 18 } 19 20 int main() { 21 scanf("%d", &t); 22 for(int ca = 1; ca <= t; ca ++){ 23 top = 0; 24 scanf("%d%d%d%d%u%u%u", &n, &p, &q, &m, &sa, &sb, &sc); 25 for(int i = 1; i <= n; i ++) { 26 if(f()%(p+q) < p) { 27 int tmp = f()%m+1; 28 st[++top] = tmp; 29 MAX[top] = max(st[top], MAX[top-1]); 30 a[i] = MAX[top]; 31 } else{ 32 if(top == 0) a[i] = 0; 33 else a[i] = MAX[--top]; 34 } 35 } 36 ll ans = 0; 37 for(ll i = 1; i <= n; i ++) { 38 ans ^= i*a[i]; 39 } 40 printf("Case #%d: %lld\n",ca,ans); 41 } 42 return 0; 43 }
B Rolling The Polygon
Bahiyyah has a convex polygon with nn vertices P_0, P_1, \cdots, P_{n-1}P0,P1,⋯,Pn−1 in the counterclockwise order.Two vertices with consecutive indexes are adjacent, and besides, P_0P0 and P_{n-1}Pn−1 are adjacent.She also assigns a point QQ inside the polygon which may appear on the border.
Now, Bahiyyah decides to roll the polygon along a straight line and calculate the length of the trajectory (or track) of point QQ.
To help clarify, we suppose P_n = P_0, P_{n+1} = P_1Pn=P0,Pn+1=P1 and assume the edge between P_0P0 and P_1P1 is lying on the line at first.At that point when the edge between P_{i-1}Pi−1 and P_iPi lies on the line, Bahiyyah rolls the polygon forward rotating the polygon along the vertex P_iPi until the next edge (which is between P_iPi and P_{i+1}Pi+1) meets the line.She will stop the rolling when the edge between P_nPn and P_{n+1}Pn+1 (which is same as the edge between P_0P