URAL1352. Mersenne Primes

梅森素数 打表

搜梅森素数的时候 看到一句话 欧拉在双目失明的情况下 用心算出了2的31次方-1是素数 他用心算的。。。

 1 #include <iostream>

 2 #include<cstdio>

 3 #include<cstring>

 4 #include<algorithm>

 5 #include<stdlib.h>

 6 #include<cmath>

 7 using namespace std;

 8 #define N 1000010

 9 int p[40]={2,3,5,7,13,17,19,31,61,89,107,127,

10 521,607,1279,2203,2281,3217,4253,4423,9689,9941,

11 11213,19937,21701,23209,44497,86243,110503,132049,

12 216091,756839,859433,1257787,1398269,2976221,3021377,6972593};

13 int main()

14 {

15     int t,n;

16     cin>>t;

17     while(t--)

18     {

19         cin>>n;

20         cout<<p[n-1]<<endl;

21     }

22     return 0;

23 }
View Code

 

你可能感兴趣的:(Prim)