UVALive - 3882:And Then There Was One
2017-11-19 23:22
369 查看
约瑟夫环
f[i]表示有i个人先处理第k个人,最后被处理的人是谁
f[i]表示有i个人先处理第k个人,最后被处理的人是谁
#include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #define MAXN 10005 using namespace std; int f[MAXN]; int n,m,k; int main() { while(1){ scanf("%d%d%d",&n,&k,&m); if(!n)break; for(int i=2;i<=n;i++){ f[i]=(f[i-1]+k)%i; } printf("%d\n",((m-k+f )%n+n)%n+1); } return 0; }
相关文章推荐
- UVALive 3882 And Then There Was One
- UVALive - 3882 And Then There Was One 约瑟夫的变形问题
- UVALive - 3882 And Then There Was One (约瑟夫环变形)@
- UVALive - 3882 And Then There Was One (递推[dp])
- UVALive 3882 And Then There Was One
- ecjtu-summer training #5 F - And Then There Was One UVALive - 3882
- uva live 3882 And Then There Was One 约瑟夫环
- And Then There Was One UVALive - 3882
- UVALive 3882 - And Then There Was One【约瑟夫问题】
- UVALive3882-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 / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)
- UVa 3882 - And Then There Was One 递推------------无力orz
- UVa 3882 - And Then There Was One 递推------------无力orz
- UVa 3882 And Then There Was One(stl+有技巧的模拟||数学方法+约瑟夫问题)
- UVA - 1394 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[约瑟夫问题的变形]