uva10006 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=35&page=show
来源:互联网 发布:java 多态 重载的区别 编辑:程序博客网 时间:2024/05/10 17:25
//题目 判断一个数n://1.是合数//2.满足a^n mod n=a。//方法://利用素数打表求出max之内的所有素数//然后利用二分思想快速幂取模运算//可以尝试一下打表做 将max内的满足的数全部找出来。#include<stdio.h>#include<math.h>#include<string.h>#define max 65010int Prim[max];void if_prim()//素数打表{ memset(Prim,-1,sizeof(Prim)); int big=(int)sqrt(max)+1; for(int i=2; i<=big; i++) if(Prim[i]) for(int j=i*i; j<max; j+=i) Prim[j]=0;}long long powmod(int a, int n, int m) //利用二分思想快速幂取模运算。{ long long res; if(n == 1) return a % m; res = powmod(a, n / 2, m); res = (res * res)% m; if(n % 2) return (res * a) % m; else return res;}int main(){ if_prim(); int n; int a; int flag; for(int n=2;n<max;n++) { flag=0; if(Prim[n]==-1) { printf("%d is normal.\n",n); continue; } for(int i=2; i<n; i++) { if(powmod(i,n,n)!=i) { printf("%d is normal.\n",n); flag=1; break; } } if(flag==0) printf("The number %d is a Carmichael number.\n",n); } return 0;}
- uva10006 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=35&page=show
- http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=35&page=show_problem&p
- 刷新页面,获得刷新后页面的页数(http://localhost:8080/option/index.jsp?page=8)
- http://appxcode.com/index.php?con=index&act=category&cid=5
- http://www.qiantu.org/index.php?p=403#comments
- 翻译http://kb.mozillazine.org/index.php?title=Extension_development
- http://bbs.redlegend.org/forumdisplay.php?fid=8&page=1 delphi学习论坛
- 踏入社会(http://www.sysinfo.cn/index.php?action=show&id=90)
- Apache中文手册http://www.cnitbar.com/main/batch.viewlink.php?itemid=886
- uva.onlinejudge.org
- http://www.cnblogs.com/zhenyulu/category/6930.html?Show=All
- http://www.cnblogs.com/wangliang651/category/61815.html?Show=All
- http://www.lihuasoft.net/news/show.php?id=4395
- http://www.facerecognition.cn/index.asp?boardid=28&page=
- 国外代理IP地址,随时跟新的,还不错 http://www.ifstar.net/proxy/index.php?act=list&page=1
- <a href="index.php?page=2">分页超级链接</a>里的?号什么意思?
- 网络蜘蛛原理~ 转 http://www.sysinfo.cn/show.php?id=35
- php <?= //show code ?> 作用
- 雁过也,月满西楼
- 修改ulimit值
- 求两数的正差值..
- 末日的爱情
- Setting Up a Selenium-WebDriver Project
- uva10006 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=35&page=show
- Winform实现滚动字幕
- 算法: 动态规划解最长公共子串
- 我的第一个c++上机报告
- winform创建非矩形窗体
- Oledb操作Excel时字段最大值255的问题解决方案
- java 日期推算
- jQuery两个有意思的切换方法
- .URL中#号(井号)的作用