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,,Pn1 in the counterclockwise order.Two vertices with consecutive indexes are adjacent, and besides, P_0P0 and P_{n-1}Pn1 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}Pi1 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

转载于:https://www.cnblogs.com/xingkongyihao/p/9338346.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值