The 2019 Asia Yinchuan First Round Online Programming

银川这波原题操作还是很秀的诶

A. Maximum Element In A Stack

思路

向栈中加入当前最大值即可。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<iostream>
#include<iomanip>
#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<string.h>
#include<cstdio>
typedef long long ll;
using namespace std;
const int Max=1e6+10;
priority_queue<int> que;
ll n,p,q,m,ans=0, max1;

unsigned int SA,SB,SC;

stack <ll> s;
unsigned int rng61()
{
SA ^= SA << 16;
SA ^= SA >> 5;
SA ^= SA << 1;
unsigned int t = SA;
SA = SB;
SB = SC;
SC ^= t ^ SA;
return SC;
}

void gen()
{
scanf("%d%d%d%d%u%u%u", &n, &p, &q, &m, &SA, &SB, &SC);
for (int i = 1; i <= n; i++)
{

if (rng61() % (p + q) < p)
{
int x = rng61() % m + 1;
if (!s.size())
s.push(x);
else if (x > s.top())
s.push(x);
else
s.push(s.top());

}
else
{
if (!s.empty())
s.pop();
else
continue;
}
if (!s.empty())
ans ^= i * s.top();
}
}

int main()
{
int T;
scanf("%d",&T);
for (int i = 1; i <= T; i++)
{
while (!s.empty())
s.pop();
ans = 0;
gen();
printf("Case #%d: %lld\n",i,ans);
}
return 0;
}
//2
//4 1 1 4 23333 66666 233333
//4 2 1 4 23333 66666 233333

B. Rolling The Polygon

思路

数学题,每个顶点对应的弧度是角度×r角度 \times r;
r用点到点的距离
角度用余弦定理,具体是piarc(cosa)pi - arc(cos a)a是顶点对应的内角,cos a就是用余弦定理

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*************************************************************************
> FileName:
> Author: Lance
> Mail: lancelot_hcs@qq.com
> Date: 9102.1.8
> Description:
************************************************************************/
//#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")//add_stack
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <vector>
#include <cstdio>
#include <bitset>
#include <string>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
const int eps = 1e-10;
const int mod = 1e9 + 7;
#define debug(a) cout << "*" << a << "*" << endl
const int INF = 0x3f3f3f3f;//int2147483647//ll9e18//unsigned ll 1e19
const int maxn = 1e5 + 5;

int t, n;
double ans;

struct node
{
int x, y;
double angel, r;
node(int _x = 0, int _y = 0, double _angel = 0, double _r = 0) : x(_x), y(_y), r(_r), angel(_angel){};
} a[maxn];

node point;

double get_r(node a, node b)
{
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}


ll read()
{
ll x = 0,f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}

int main()
{
// ios::sync_with_stdio(false);
scanf("%d", &t);
for (int k = 1; k <= t; k++)
{
ans = 0;
n = read();
for (int i = 0; i < n; i++)
{
a[i].x = read();
a[i].y = read();
}
point.x = read();
point.y = read();

for (int i = 0; i < n; i++)
{
a[i].r = get_r(a[i], point);
double d1 = get_r(a[i], a[(i + 1) % n]);
double d2 = get_r(a[i], a[(i + n - 1) % n]);
double d3 = get_r(a[(i + 1) % n], a[(i + n - 1) % n]);
ans += sqrt(a[i].r) * (pi - acos((d1 + d2 - d3) / (2 * sqrt(d1) * sqrt(d2)))) ;
}

printf("Case #%d: %.3lf\n", k, ans);
}
return 0;
}


F. Moving On

思路

代码

1

L. Continuous Intervals

思路

代码

1

I. Bubble Sort

思路

代码

1

E. 2-3-4 Tree

思路

代码

1