Carmichael Numbers
来源:互联网 发布:jeep镜框 知乎 编辑:程序博客网 时间:2024/06/17 07:43
#include<iostream>#include<algorithm>using namespace std;int main(int ac,char *av[]){ int arr[15]={561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, 52633, 62745, 63973 };//( 2 < n < 65000)间的Carmichael Numbers int n; while(cin>>n,n) { if(binary_search(arr,arr+15,n)) cout << "The number " << n << " is a Carmichael number." << endl; if(!binary_search(arr,arr+15,n)) cout << n << " is normal." << endl; } return 0;}
Carmichael Numbers
Description
Carmichael Numbers
An important topic nowadays in computer science is cryptography. Some people even think that cryptography is the only important field in computer science, and that life would not matter at all without cryptography. Alvaro is one of such persons, and is designing a set of cryptographic procedures for cooking paella. Some of the cryptographic algorithms he is implementing make use of big prime numbers. However, checking if a big number is prime is not so easy. An exhaustive approach can require the division of the number by all the prime numbers smaller or equal than its square root. For big numbers, the amount of time and storage needed for such operations would certainly ruin the paella.However, some probabilistic tests exist that offer high confidence at low cost. One of them is the Fermat test.
Let a be a random number between 2 andn - 1 (beingn the number whose primality we are testing). Then,n is probably prime if the following equation holds:
![\begin{displaymath}a^n \bmod n = a\end{displaymath}](http://uva.onlinejudge.org/external/100/10006img1.gif)
If a number passes the Fermat test several times then it is prime with a high probability.
Unfortunately, there are bad news. Some numbers that are not prime still pass the Fermat test with every number smaller than themselves. These numbers are called Carmichael numbers.
In this problem you are asked to write a program to test if a given number is a Carmichael number. Hopefully, the teams that fulfill the task will one day be able to taste a delicious portion of encrypted paella. As a side note, we need to mention that, according to Alvaro, the main advantage of encrypted paella over conventional paella is that nobody but you knows what you are eating.
Input
The input will consist of a series of lines, each containing a small positive numbern ( 2 <n < 65000). A number n = 0 will mark the end of the input, and must not be processed.Output
For each number in the input, you have to print if it is a Carmichael number or not, as shown in the sample output.Sample Input
17291756111094310
Sample Output
The number 1729 is a Carmichael number.17 is normal.The number 561 is a Carmichael number.1109 is normal.431 is normal.
- Carmichael Numbers
- Carmichael Numbers
- Carmichael Numbers
- UVa 10006 Carmichael Numbers
- uva 10006 - Carmichael Numbers
- UVa10006 - Carmichael Numbers
- UVA 10006 Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- Uva - 10006 - Carmichael Numbers
- 10006 - Carmichael Numbers
- uva10006 - Carmichael Numbers
- UVaOJ10006 - Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- UVA - 10006 Carmichael Numbers
- UVa 10006 - Carmichael Numbers
- 110702 Carmichael Numbers
- UVa 10006 Carmichael Numbers
- Carmichael Numbers - PC110702
- hibernate HQl 语言
- jython对hadoop的封装项目
- WebService for Android
- Hadoop安装注意IPV6问题
- 十六周任务二之成绩的读入与输出
- Carmichael Numbers
- Mercurial Queues (MQ) <一>
- POI读取Excel浅谈
- 简析linux内核的执行流程(从bootsect.s到启动结束)
- HashSet
- uva644 - Immediate Decodability
- DataGridView转换成相对应的DataRow
- 在VC6.0下面如何调用matlab的程序
- 为myeclipse增加反编译功能