Codeforces Round #257 (Div. 2)
来源:互联网 发布:免费cms源代码php 编辑:程序博客网 时间:2024/05/29 18:56
还是只做了2道。哎,虽然速度比之前快了些。
A. Jzzhu and Children
题意:输入n、m,输入n个数,每个数代表第i个孩子需要的糖果数,m代表每次能分发的糖果数。现在让孩子依次来领糖果,如果发了m个糖果后还需要的孩子就排到队伍末尾继续领糖果。输出最后一个领糖果的孩子是第几个孩子。
思路:队列模拟
#include <stdio.h>#include <queue>#include <string.h>#include <algorithm>using namespace std;struct dd{ int pos; int need;}a[105];int main(){ int n,m; scanf("%d%d",&n,&m); queue<dd> q; for(int i=0;i<n;i++){ scanf("%d",&a[i].need); a[i].pos=i+1; q.push(a[i]); } while(q.size()>1){ dd t=q.front(); q.pop(); t.need-=m; if(t.need>0) q.push(t); } printf("%d\n",q.front().pos); return 0;}
B. Jzzhu and Sequences
题意:计算 fn对1000000007 (109 + 7)取余的结果。
思路:求出前7~8项便可发现规律。注意的是负数取余应先加到正数后再取余。
#include <stdio.h>#include <queue>#include <string.h>#include <algorithm>using namespace std;const long long mod=1000000007;long long change(long long tt){ if(tt>0) tt%=mod; while(tt<0) tt+=mod; return tt;}int main(){ long long f1,f2,n; scanf("%I64d%I64d%I64d",&f1,&f2,&n); long long a[6]; a[0]=change(f1); a[1]=change(f2); a[2]=change(f2-f1); a[3]=change(-f1); a[4]=change(-f2); a[5]=change(f1-f2); printf("%I64d\n",a[(n-1)%6]); return 0;}
0 0
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- CodeForces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2) C题
- Codeforces Round #257 (Div. 2) 题解
- Codeforces Round #257 (Div. 2) ABCD
- Codeforces Round #256, 257 (Div. 2)
- 【索引】Codeforces Round #257 (Div. 2)
- Codeforces Round #257 (Div. 2) D
- Codeforces Round #257 (Div. 1)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- POJ 1789 Truck History(最小生成树)
- Linux扩展权限
- 杂谈:行业的变迁
- Eclipse学习系列 -- TCP/IP Monitor
- oracle中的rownum和同义词用法
- Codeforces Round #257 (Div. 2)
- poj2240 Arbitrage 图论,Floyd变形
- UITextField属性--PlaceHolder颜色自定义
- 巧用union实现整数高低位拆分
- QT学习笔记(一)
- 通过视频图像和盲源分离方式非接触、自动测量心跳
- POJ 1274 The Perfect Stall 水二分匹配
- 空气循环扇
- hdu1034 简单模拟