UVA 10006 Carmichael Numbers
来源:互联网 发布:ios9.0.2软件源 编辑:程序博客网 时间:2024/05/01 21:32
#include <map>#include <set>#include <list>#include <cmath>#include<cctype>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cstdio>#include <string>#include <vector>#include<climits>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}bool prime[66000];LL N;void init(){ for (int i=0;i<66000;i++) prime[i]=true; prime[0]=prime[1]=false; for (int i=2;i*i<66000;i++) if (prime[i]) for (int j=i+i;j<66000;j+=i) prime[j]=false;}LL pow_mod(LL a,LL b,LL m){ LL ans=1; a%=m; while (b) { if (b&1) ans=(ans*a)%m; a=(a*a)%m; b>>=1; } return ans;}int main(){ init(); while (scanf("%lld",&N)!=EOF) { if (N==0) break; if (prime[N]) {printf("%lld is normal.\n",N);continue;} bool flag=false; for (LL i=2;i<N;i++) if (pow_mod(i,N,N)!=i) { flag=true; break; } if (flag) printf("%lld is normal.\n",N); else printf("The number %lld is a Carmichael number.\n",N); } return 0;}
0 0
- UVa 10006 Carmichael Numbers
- uva 10006 - Carmichael Numbers
- UVA 10006 Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- Uva - 10006 - Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- UVA - 10006 Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- UVa 10006 Carmichael Numbers
- uva 10006 Carmichael Numbers
- uva 10006 Carmichael Numbers
- UVA 10006 Carmichael Numbers
- UVA 10006 Carmichael Numbers
- UVA - 10006 Carmichael Numbers
- UVA 10006 Carmichael Numbers
- UVa-10006 Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- uva 10006 Carmichael Numbers
- 移动端开发面试准备
- Oracle中生成随机数UUID的方法(sys_guid())
- EEPlat订单管理系统开发(零)之__简介及初始配置
- Objective C中数组排序几种情况的总结
- Mockito简单介绍及示例
- UVA 10006 Carmichael Numbers
- <%@ page isELIgnored="false"%>的作用
- EBS相关代码上传方式
- C# 进制转换参考
- windows网络编程【003】实现简单WSASocket的C/S结构-_-!~~~~~~
- LIB和DLL的区别与使用
- Linux内核等待队列机制介绍
- 关于python文件操作
- 最简实例说明wait、notify、notifyAll的使用方法