Round #432 (Div.2)

A. Arpa and a research in Mexican wave
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

 
Input

The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).

 
Output

Print single integer: how many spectators are standing at time t.

 
Examples
 
Input
10 5 3
 
Output
3
 
Input
10 5 7
 
Output
5
 
Input
10 5 12
 
Output
3
 
Note

In the following a sitting spectator is represented as -, a standing spectator is represented as ^.

  • At t = 0  ---------- number of standing spectators = 0.
  • At t = 1  ^--------- number of standing spectators = 1.
  • At t = 2  ^^-------- number of standing spectators = 2.
  • At t = 3  ^^^------- number of standing spectators = 3.
  • At t = 4  ^^^^------ number of standing spectators = 4.
  • At t = 5  ^^^^^----- number of standing spectators = 5.
  • At t = 6  -^^^^^---- number of standing spectators = 5.
  • At t = 7  --^^^^^--- number of standing spectators = 5.
  • At t = 8  ---^^^^^-- number of standing spectators = 5.
  • At t = 9  ----^^^^^- number of standing spectators = 5.
  • At t = 10 -----^^^^^ number of standing spectators = 5.
  • At t = 11 ------^^^^ number of standing spectators = 4.
  • At t = 12 -------^^^ number of standing spectators = 3.
  • At t = 13 --------^^ number of standing spectators = 2.
  • At t = 14 ---------^ number of standing spectators = 1.
  • At t = 15 ---------- number of standing spectators = 0.

 

 

 1 #include <iostream> 
 2 #include <string.h> 
 3 using namespace std;
 4 int main(){
 5     int n,k,t;
 6     while(cin>>n>>k>>t){
 7         if(t<k) cout<<t<<endl;
 8         else if(t>n) cout<<k-(t-n)<<endl;
 9         else cout<<k<<endl;
10     }
11     
12 }

 

B. Arpa and an exam about geometry
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

 

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.

 
Input

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.

 
Output

Print "Yes" if the problem has a solution, "No" otherwise.

You can print each letter in any case (upper or lower).

 
Examples
 
Input
0 1 1 1 1 0
 
Output
Yes
 
Input
1 1 0 0 1000 1000
 
Output
No
Note

In the first sample test, rotate the page around (0.5, 0.5) by .

In the second sample test, you can't find any solution.

 

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     double ax,ay,bx,by,cx,cy;
 5     while(cin>>ax>>ay>>bx>>by>>cx>>cy){
 6         double d1=(by-ay)*(by-ay)+(bx-ax)*(bx-ax);
 7         double d2=(cy-by)*(cy-by)+(cx-bx)*(cx-bx);
 8         if(d1!=d2) cout<<"No"<<endl;
 9         else {
10             double k1=(by-ay)/(bx-ax);
11             double k2=(cy-by)/(cx-bx);
12             if(k1==k2) cout<<"No"<<endl;
13             else cout<<"Yes"<<endl;
14         } 
15     } 
16     
17 }

 

 

 

 

posted @ 2017-09-15 19:43  浅忆~  阅读(138)  评论(0编辑  收藏  举报