zrq495
www.zrq495.com
摘要: L=(Z*L + I)%M,求L的循环周期。注意L不一定是在初始位置开始循环。哈希 数组标记出现过的L,判断即可。代码如下: 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 5 using namespace std; 6 7 int main() 8 { 9 long long a[10001], l, z, i, m, cnt, cas=1;10 while(cin >> z >> i >> m >> l, z||i||m||l)1 阅读全文
posted @ 2012-08-11 21:17 zrq495 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 判断是否互质数。注意输出格式。代码: 1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int gcd(int a, int b) //求最大公约数 7 { 8 return b? gcd(b, a%b) : a; 9 }10 11 int main()12 {13 int s, m;14 while(cin >> s >> m)15 {16 if (gcd(s, m) == 1)17 printf("%10d%10d ... 阅读全文
posted @ 2012-08-11 16:28 zrq495 阅读(203) 评论(0) 推荐(0) 编辑