Codeforces 851A && Round #432 Div. 2 A. Arpa and a research in Mexic
2017-09-05 08:41
691 查看
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 from1 ton. They start the Mexican wave at time0.
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
Output
Input
Output
Input
Output
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.
题目大意:有n个观众,给你一个k(不懂怎么解释....),再给你一个时间t,问t时刻有多少人站起来。
水题,找个规律就行了
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 from1 ton. They start the Mexican wave at time0.
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.
题目大意:有n个观众,给你一个k(不懂怎么解释....),再给你一个时间t,问t时刻有多少人站起来。
水题,找个规律就行了
#include<iostream> #include<cstring> using namespace std; int main(){ int n,k,t; while(cin>>n>>k>>t){ if(t<k) cout<<t<<endl; else if(t>n) cout<<k-(t-n)<<endl; else cout<<k<<endl; } }
相关文章推荐
- Codeforces 851B && Round #432 Div. 2 B. Arpa and an exam about geometry
- 【Codeforces Round #432 (Div. 2) A】 Arpa and a research in Mexican wave
- Codeforces 851 A Arpa and a research in Mexican wave
- Codeforces Round #432 (Div. 2) - A - Arpa and a research in Mexican wave
- Codeforces 851A - Arpa and a research in Mexican wave - 水题
- ACM刷题之codeforce————Arpa and a research in Mexican wave
- Codeforces Round #432 (Div. 2) (Codeforces 850C) E. Arpa and a game with Mojtaba 博弈+状态压缩
- Codeforces Round #383 (Div. 2)C. Arpa's loud Owf and Mehrdad's evil plan(dfs&lcm)
- A - Arpa and a research in Mexican wave
- A. Arpa and a research in Mexican wave
- [树上启发式合并 && 哈希] Codeforces 741D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
- A. Arpa and a research in Mexican wave
- Codeforces 432 Div. 2-D-Arpa and a list of numbers(枚举倍数求GCD)
- [广义后缀自动机] BZOJ 3473 字符串 & BZOJ 3277 串 & Codeforces 204E #129 (Div. 1) E. Little Elephant and Strings
- Codeforces Round #210 (Div. 2) C. Levko and Array Recovery && Codeforces 360 A 详解(思维+维护理论值)
- 【Codeforces 718C&719E】Sasha and Array【线段树成段更新+矩阵快速幂】
- Codeforces 711 E. ZS and The Birthday Paradox(数学)——Codeforces Round #369 (Div. 2)
- Codeforces 742B-Arpa’s obvious problem and Mehrdad’s terrible solution
- codeforces 545 Round #303 (Div. 2) E Paths and Trees
- "AND" in linq? is it possible?