# 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 4529 Double Dealing (置换群)的更多相关文章

  1. hdu 4259 Double Dealing

    思路: 找每一个数的循环节,注意优化!! 每次找一个数的循环节时,记录其路径,下次对应的数就不用再找了…… 代码如下: #include<iostream> #include<cst ...

  2. HDU 4259 - Double Dealing(求循环节)

    首先将扑克牌进行一次置换,然后分解出所有的循环节,所有循环节的扑克牌个数的最小公倍数即为答案 #include <stdio.h> #include <string.h> #i ...

  3. HDU 4259(Double Dealing-lcm(x1..xn)=lcm(x1,lcm(x2..xn))

    Double Dealing Time Limit: 50000/20000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDOJ 4259 Double Dealing

    找每一位的循环节.求lcm Double Dealing Time Limit: 50000/20000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  5. HDU 4529 郑厂长系列故事——N骑士问题 状压dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4529 郑厂长系列故事--N骑士问题 Time Limit: 6000/3000 MS (Java/O ...

  6. hdu 1908 Double Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1908 Double Queue Description The new founded Balkan ...

  7. HDU 1568 double 快速幂

    Fibonacci Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  8. POJ 3481 &amp; HDU 1908 Double Queue (map运用)

    题目链接: PKU:http://poj.org/problem?id=3481 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1908 Descript ...

  9. HDU 1908 Double Queue(set)

    Problem Description The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in B ...

随机推荐

  1. 十分钟开发一个调用Activity的PhoneGap插件

    在HybridApp开发中,非常多业务我们是没有办法通过HTML5+js实现的,比方调用第三方的包括Activity的jar包,一些必须使用原生代码才干实现的功能,比方复杂的UI的效果,调用通讯相关的 ...

  2. C# - ref

    The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by ...

  3. kernel hexdump分析

    驱动调试中,很多时候是二进制的,这个时候hexdump就是个非常有用的工具了. 不要再自己去实现类似的功能,kernel代码里面就有: 参考: kernel/lib/hexdump.c // 0Xxx ...

  4. jeecg智能开发平台参与-2013年度中国优秀开源项目评比

    JEECG正在参与<2013年度中国十大优秀开源项目> 评比,如果大家觉得JEECG还不错, 请投出你宝贵的一票,给我们以支持吧!!! [目前排名第8位] https://code.csd ...

  5. 4.Swift教程翻译系列——Swift基本运算符

    英文版PDF下载地址http://download.csdn.net/detail/tsingheng/7480427 运算符是指一个特殊的符号,能够用来查看.更改值或者相加.比方说加法运算符+能够讲 ...

  6. Exception in thread "main" java.net.BindException: Address already in use: JVM_Bind

    Exception in thread "main" java.net.BindException: Address already in use: JVM_Bind    at ...

  7. Qt移动版优化后台云服务、支持跨平台开发

    http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5MDE0Mjc4MA==&appmsgid=10000461&itemidx=2&am ...

  8. Qt4在linux下的安装

    1.下载SDK ftp://ftp.informatik.hu-berlin.de/pub/Mirrors/ftp.troll.no/QT/qtsdk/qt-sdk-linux-x86-opensou ...

  9. 【读书笔记】《未来闪影》罗伯特·J·索耶

    真是一本引人入胜的书! 看了不到一半,就有一种置身其中的感觉,要是我也能看到自己二十年后的生活,哪怕只有1分43秒,该是一件多么奇妙的事情.但忧虑也随之而来,如果二十年后我没有成为现在想成为的人,现在 ...

  10. JSP/Servlet-----charset 、pageEncoding差别

    一.JSP/Servlet中的几个编码的作用         在JSP/Servlet中有4个地方可设置编码(例如以下).当中前两个仅仅能用于JSP中,后两个可用于JSP和Servlet 中.    ...