题目
原题链接:A. Arpa and a research in Mexican wave
题意
给出n个座位,k个人,问t时刻座位中有几个人。
如下所示:
- 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
using namespace std;
int main() {
int n,k,t;
cin>>n>>k>>t;
if(t==0) {
printf("0\n");
return 0;
}
int tt=t%(n+k);
if(tt<=k) {
printf("%d\n",tt);
} else if(tt>=n) {
printf("%d\n",(n+k)-tt);
} else {
printf("%d\n",k);
}
return 0;
}