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;
}
一直在做数学题,跳出来一道水模拟。。。
就是找循环节
#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 1597 Uniform Generator 模拟
- poj 1019 Number Sequence && hdu 1597 find the nth digit(二分,模拟)
- 文章标题poj 1107:W's Cipher (模拟)
- CodeForces 600D Area of Two Circles' Intersection 圆面积交 (POJ 2546, ZOJ 1597)
- POJ 3750 小孩报数问题 (线性表思想 约瑟夫问题 数组模拟运算的 没用循环链表,控制好下标的指向就很容易了)
- poj 1606 Jugs and poj 3414 Pots(数组模拟BFS) uva 571 (数论)
- [POJ][2069][Super Star][模拟退火]
- POJ 1068 Parencodings 模拟 栈操作
- POJ 2014:Flow Layout 模拟水题
- POJ 2069 Super Star(模拟退火,最小球覆盖)
- poj 1597 Uniform Generator
- POJ 2081 Recaman's Sequence(模拟/暴力)
- poj 3087 直接模拟
- poj 1005:I Think I Need a Houseboat(水题,模拟)
- poj 2106 Boolean Expressions(模拟)
- ZOJ 1423 (Your)((Term)((Project))) (POJ 1690) (模拟)
- poj 1068 Parencodings(模拟)
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
- POJ 1017 Packets 【贪心 模拟】
- poj 1552 Doubles(简单的模拟一下)