LA3882 And Then There Was One
来源:互联网 发布:乐高 t r3x 编程下载 编辑:程序博客网 时间:2024/06/06 02:16
题目描述 传送门
蓝书上的例题,递推法求之。
设
最终答案是 (f[n]+m-k+1)%n 注意可能是负数,还要处理一下。
代码
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;int f[10010];int main(){ int n,k,m; f[1]=0; while(scanf("%d%d%d",&n,&k,&m)==3&&!(!n&&!k&&!m)){ for(int i=2;i<=n;i++) f[i]=(f[i-1]+k)%i; int ans=(f[n]+m-k+1)%n; while(ans<=0) ans+=n; printf("%d\n",ans); } return 0;}
阅读全文
0 0
- LA3882 And Then There Was One
- LA3882 And Then There Was One
- And Then There Was One
- And Then There Was One
- POJ 3517 And Then There Was One
- POJ 3157 And Then There Was One
- pku3517 And Then There Was One
- And Then There Was One----约瑟夫环
- POJ-3517-And Then There Was One
- uva 1394 - And Then There Was One
- UVA 1394 And Then There Was One
- UVALive 3882 And Then There Was One
- UVALive 3882 And Then There Was One
- UVa 1394: And Then There Was One
- UVa:1394 And Then There Was One
- LA-3882 And Then There Was One
- POJ 3517 And Then There Was One
- POJ 3517 And Then There Was One
- HDU
- 算法 第四版 1.4.16
- angular之表单验证ngMessages
- C++的继承中构造和析构函数的调用顺序
- Eclipse Debug界面详解
- LA3882 And Then There Was One
- C#选择文件 文件夹
- sdf
- 前端路由 -- vue-router
- 算法 1.4.17
- Timer
- CF #433 DIV2 B. Maxim Buys an Apartment
- 说说云盘背后的黑科技!
- 20. Valid Parentheses