hdu 4529 Double Dealing (置换群)
HDU double
2023-09-14 09:10:21 时间
# include <stdio.h> # include <algorithm> # include <string.h> using namespace std; __int64 gcd(__int64 a,__int64 b) { if(b==0) return a; return gcd(b,a%b); } int main() { int n,k,i,j,vis[810],m,num[810],x; __int64 res,cot; while(~scanf("%d%d",&n,&k),n+k) { m=1; for(i=1; i<=k&&i<=n; i++) //第一次分完牌 for(j=(n-i)/k*k+i; j>0; j-=k) num[m++]=j; res=1; memset(vis,0,sizeof(vis)); for(i=1; i<=n; i++) { if(vis[i]) continue; x=i; cot=0; while(1) { vis[x]=1; cot++; x=num[x]; if(i==x) break; } res=res/gcd(res,cot)*cot; } printf("%I64d\n",res); } return 0; }
相关文章
- hdu 3506 Monkey Party 区间DP+四边形不等式优化
- HDU 3920 Clear All of Them I(DP + 状态压缩 + 贪心)
- HDU 2502 月之数(简单递推)
- HDU 1074 Doing Homework (dp+状态压缩)
- 【hdu 6208】The Dominator of Strings
- 【hdu 1068】Girls and Boys
- HDU 5296 Annoying problem
- HDU 4280 Island Transport(网络流)
- hdu 4869 Turn the pokers
- HDU 1432 Lining Up (POJ 1118)
- HDU 1248 寒冰王座(全然背包:入门题)
- hdu 2222 Keywords Search ac自己主动机
- hdu 5071 Chat(模拟|Splay)
- HDU 4777 Rabbit Kingdom(树状数组)
- 【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection
- HDU 3313 Key Vertex(dfs + bfs)