您的位置:首页 > 其它

poj 1597(水模拟)

2013-07-22 19:43 447 查看
点击打开链接

一直在做数学题,跳出来一道水模拟。。。

就是找循环节

#include"stdio.h"
#include"string.h"
#define N 100001
int n,m;
int mark
;
void fun()
{
int i;
int ans;
memset(mark,0,sizeof(mark));
ans=0;
mark[0]=1;
for(i=0;i<m;i++)
{
ans=(ans+n)%m;
if(mark[ans]==1)break;
mark[ans]=1;
}
for(i=0;i<m;i++)
if(mark[i]!=1)break;
if(i>=m)printf("%10d%10d%s\n",n,m," Good Choice");
else printf("%10d%10d%s\n",n,m," Bad Choice");
printf("\n");
}

int main()
{
while(scanf("%d%d",&n,&m)!=-1)
fun();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  找循环节 poj 模拟