Codeforces 851 A Arpa and a research in Mexican wave

来源:互联网 发布:用js做一个登录界面 编辑:程序博客网 时间:2024/05/18 03:35

题目地址
题意:你有n个人的一排,你要做出一个长为k的人浪,问第k秒的时候有多少个人站着。
思路:该题目就只会出现3种情况:

  • 1、t<=k的时候,当前的人数为t
  • 2、当t>n的时候,当前的人数为k-(t-n)
  • 3、否则,当前的人数为n

判断这3种情况就好了。

#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#include <iomanip>#define N 1000010#define M 4000010#define LL __int64#define inf 0x7f7f7f7f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;int main() {    cin.sync_with_stdio(false);    LL 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;    }    return 0;}
阅读全文
0 0
原创粉丝点击