A. Arpa and a research in Mexican wave
来源:互联网 发布:移动80端口 编辑:程序博客网 时间:2024/05/17 23:09
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputArpa 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.
解题说明:此题是一道模拟题,按照题目意思求解即可。
#include<cstdio>#include<iostream>#include<string>#include<cstring>using namespace std;int main() {int n, k, t;scanf("%d %d %d", &n, &k, &t);if (t >= k && t <= n){printf("%d\n", k);}else if (t > n){printf("%d\n", k - (t - n));}else{printf("%d\n", t);}return 0;}
阅读全文
0 0
- Codeforces 851 A Arpa and a research in Mexican wave
- CF 851A Arpa and a research in Mexican wave
- A. Arpa and a research in Mexican wave
- Codeforces 851A Arpa and a research in Mexican wave
- 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 851A && Round #432 Div. 2 A. Arpa and a research in Mexic
- CF850B-Arpa and a list of numbers
- CF_850B Arpa and a list of numbers
- Understand Wave Format, and Implement a Wave Reader
- ParaView Used in a Mining Research Environment
- A. Arpa’s hard exam and Mehrdad’s naive cheat
- codeforces 850B Arpa and a list of numbers
- Codeforces 851E-Arpa and a game with Mojtaba
- CF850B Arpa and a list of numbers【思路】
- Codeforces 851D. Arpa and a list of numbers
- Codeforces851D Arpa and a list of numbers(素数筛)
- 仿facebook
- 如何把java程序作为Linux服务启动
- 全新体验—Eclipse更换代码颜色与风格!
- 数据结构与算法之线性表(一)
- 黑胡子之谜
- A. Arpa and a research in Mexican wave
- this、call和apply
- Codeforces862C. Mahmoud and Ehab and the xor 【构造】
- LeetCode-69-Sqrt(x) Python要用math.sqrt()
- ==与equals的区别
- JMP二次开发方法研究
- Go 语言中格式化时间
- systemctl命令
- python学习笔记