A. Arpa and a research in Mexican wave
Arpa is researching the Mexican wave.
There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.
- At time 1, the first spectator stands.
- At time 2, the second spectator stands.
- ...
- At time k, the k-th spectator stands.
- At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.
- At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.
- ...
- At time n, the n-th spectator stands and the (n - k)-th spectator sits.
- At time n + 1, the (n + 1 - k)-th spectator sits.
- ...
- At time n + k, the n-th spectator sits.
Arpa wants to know how many spectators are standing at time t.
The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).
Print single integer: how many spectators are standing at time t.
10 5 3
3
10 5 7
5
10 5 12
3 三个判断
1 #include2 #define ll long long 3 using namespace std; 4 const int N = 110; 5 int main(){ 6 int n, k, t; 7 cin >> n >> k >> t; 8 if(t <= k) { 9 printf("%d\n",t);10 } else if(t <= n) {11 printf("%d\n",k);12 } else {13 printf("%d\n",k+n-t);14 }15 return 0;16 }
B. Arpa and an exam about geometry
Arpa is taking a geometry exam. Here is the last problem of the exam.
You are given three points a, b, c.
Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.
Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.
The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.
Print "Yes" if the problem has a solution, "No" otherwise.
You can print each letter in any case (upper or lower).
0 1 1 1 1 0
Yes
1 1 0 0 1000 1000
No 如果abc三点共线或者|ab| != |bc| 就时No 否则就时Yes 可惜三点共线没写好,总测没过去。
1 #include2 #define ll long long 3 using namespace std; 4 const int N = 110; 5 struct Point{ 6 ll x, y; 7 }a[4]; 8 ll dist(Point aa, Point b) { 9 return (aa.x-b.x)*(aa.x-b.x)+(aa.y-b.y)*(aa.y-b.y);10 }11 bool cmp(Point x, Point y) {12 return x.x < y.x;13 }14 bool check(){15 sort(a+1,a+4,cmp);16 if((a[2].y-a[1].y)*(a[3].x-a[2].x) == (a[3].y-a[2].y)*(a[2].x-a[1].x)) return true;17 18 return false;19 }20 int main(){21 cin >> a[1].x >> a[1].y >> a[2].x >> a[2].y >> a[3].x >> a[3].y;22 if(dist(a[1],a[2]) != dist(a[2],a[3])){23 return 0*printf("No\n");24 } else if(check()){25 return 0*printf("No\n");26 }else {27 printf("Yes\n");28 }29 return 0;30 }
C. Five Dimensional Points
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.
We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors and is acute (i.e. strictly less than ). Otherwise, the point is called good.
The angle between vectors and in 5-dimensional space is defined as , where is the scalar product and is length of .
Given the list of points, print the indices of the good points in ascending order.
The first line of input contains a single integer n (1 ≤ n ≤ 103) — the number of points.
The next n lines of input contain five integers ai, bi, ci, di, ei (|ai|, |bi|, |ci|, |di|, |ei| ≤ 103) — the coordinates of the i-th point. All points are distinct.
First, print a single integer k — the number of good points.
Then, print k integers, each on their own line — the indices of the good points in ascending order.
6 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
1 1
3 0 0 1 2 0 0 0 9 2 0 0 0 5 9 0
0 可以直接暴力过。
1 #include2 #define ll long long 3 using namespace std; 4 const int N = 1010; 5 struct Point{ 6 ll a, b, c, d, e; 7 }nod[N]; 8 bool vis[N]; 9 ll check(Point aa, Point bb, Point cc) {10 return (bb.a-aa.a)*(cc.a-aa.a)+(bb.b-aa.b)*(cc.b-aa.b)+(bb.c-aa.c)*(cc.c-aa.c)+(bb.d-aa.d)*(cc.d-aa.d)+(bb.e-aa.e)*(cc.e-aa.e);11 }12 int main(){13 int n;14 memset(vis, true, sizeof(vis));15 cin >> n;16 for(int i = 1; i <= n; i ++) {17 cin >> nod[i].a >> nod[i].b >> nod[i].c >> nod[i].d >> nod[i].e;18 }19 int k = n;20 for(int i = 1; i <= n; i ++) {21 for(int j = 1; j <= n; j ++) {22 for(int l = j+1; l <= n; l ++) {23 if(i != j && i != l) {24 if(check(nod[i], nod[j], nod[l]) > 0) {25 vis[i] = false;26 k--;27 goto tt;28 }29 }30 }31 }32 tt:;33 }34 printf("%d\n",k);35 int cnt = 0;36 for(ll i = 1; i <= n; i ++) {37 if(vis[i]) {38 cnt ++;39 printf("%lld ",i);40 }41 }42 if(k!=0)printf("\n");43 return 0;44 }