1352. Mersenne Primes

Time limit: 1.0 second
Memory limit: 64 MB
Definition. If the number 2N−1 is prime then it is called a Mersenne prime number.
For example, 22−1 — the first Mersenne prime, 23−1 — the second Mersenne prime, 211213−1 — the 23rd, 2216091−1 — the 31st.
It’s a hard problem to find those numbers without a computer. So, Euler in 1772 found the 8thMersenne prime — 231−1 and then for 100 years no Mersenne prime was found! Just in 1876 Lucas showed that 2127−1 is a prime number. But he didn’t find the 9th Mersenne prime, it was the 12thone (the numbers 261−1, 289−1 and 2107−1 are prime but it was found out later). A new break-through happened only in 1950’s when with the help of the computing machinery Mersenne primes with the powers 521, 607, 1279, 2203 and 2281 were found. All the following Mersenne primes were found with the help of computers. One needn’t be a great mathematician to do that. In 1978 and 1979 students Noll and Nickel found the 25th and 26th numbers (21701 and 23209) on the mainframe of their University and they became famous all over the USA. But the modern supercomputers have the limits of their capability. Today the dozens of thousands people all over the world united in one metaproject GIMPS (Great Internet Mersenne Prime Search, www.mersenne.org) look for Mersenne primes. GIMPS found 8 the greatest Mersenne primes. Their powers are 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951. 26972593−1 is the 38th Mersenne prime, and for the last 4 numbers one can’t tell what are their sequence numbers because not all the lower numbers are checked. Those four numbers are also the greatest known prime numbers.
The latest number 225964951−1 was found on February 18, 2005, it contains 7816230 decimal digits. The one who will find a prime number with more than 10 millions digits will get a prize of $100000. You may gain the prize if you join the project.
You are not now to find the 43th Mersenne prime — the jury won’t be able to check your answer. Ndoesn’t exceed 38 in this problem. So, given an integer N you are to find Nth Mersenne prime.
(Information is actual for March, 2005)

Input

The first line contains integer T — an amount of tests. Each of the next T lines contains an integer N.

Output

For each N you should output the power of the Nth by order Mersenne prime.

Sample

input output
13
18
32
24
21
19
34
27
33
20
30
28
29
22
3217
756839
19937
9689
4253
1257787
44497
859433
4423
132049
86243
110503
9941

题意:梅森素数:m=2^p-1,如果m是素数,则m被称为梅森素数,题意要求求出第i个梅森素数所对应的p的值

思路;梅森素数现在一共有43个,我们将他们所有的所对应的p值进行枚举

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string> using namespace std; int kiss[]={,,,,,,,,,,,
,,,,,,,,,,
,,,,,,,,,,
,,,,,,,}; int main()
{
int T;
scanf("%d",&T);
while(T){
int n;
scanf("%d",&n);
printf("%d\n",kiss[n]);
T--;
}
return ;
}

ural 1352. Mersenne Primes的更多相关文章

  1. URAL1352. Mersenne Primes

    梅森素数 打表 搜梅森素数的时候 看到一句话 欧拉在双目失明的情况下 用心算出了2的31次方-1是素数 他用心算的... #include <iostream> #include<c ...

  2. Project Euler 97 :Large non-Mersenne prime 非梅森大素数

    Large non-Mersenne prime The first known prime found to exceed one million digits was discovered in ...

  3. Effective Java 第三版——45. 明智审慎地使用Stream

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  4. Effective Java 第三版——48. 谨慎使用流并行

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  5. Codeforces225E - Unsolvable

    Portal Description 求所有对于方程\[z=\left \lfloor \frac{x}{2} \right \rfloor+y+xy\]不存在正整数解\((x,y)\)的\(z\)中 ...

  6. UVA 583 分解质因数

    Webster defines prime as:prime (prim) n. [ME, fr. MF, fem. of prin first, L primus; akin to L prior] ...

  7. [Java读书笔记] Effective Java(Third Edition) 第 7 章 Lambda和Stream

    在Java 8中,添加了函数式接口(functional interface),Lambda表达式和方法引用(method reference),使得创建函数对象(function object)变得 ...

  8. sicily 1009. Mersenne Composite N

    Description One of the world-wide cooperative computing tasks is the "Grand Internet Mersenne P ...

  9. [LeetCode] Count Primes 质数的个数

    Description: Count the number of prime numbers less than a non-negative number, n click to show more ...

随机推荐

  1. Swift3GCD

    GCD的使用在Swift3中的方法 //串行队列 let q:DispatchQueue = DispatchQueue(label: "xiaosi") //并发队列 qos : ...

  2. Android Studio新手

    目标:Android Studio新手–>下载安装配置–>零基础入门–>基本使用–>调试技能–>构建项目基础–>使用AS应对常规应用开发 AS简介 经过2年时间的研 ...

  3. PHP22期基础班技术总结

  4. 简单的jquery ajax文件上传功能

    /* * 图片上传 * 注意如果不加processData:false和contentType:false会报错 */ function uploadImage(image) { var imageF ...

  5. Oracle数据库创建数据库实例1

    http://jingyan.baidu.com/article/ae97a646d128d5bbfd461d00.html

  6. Request.UrlReferrer为空的问题

    Request.UrlReferrer为空的问题   今天在开发时遇到了一个问题,在用Request.UrlReferrer获取上一页面的地址时发现该对象为空(IE下,FF下可以得到对象),于是上网搜 ...

  7. postgreSQL-如何查数据库表、字段以及字段类型、注释等信息?

    之前从网上也搜索了一些关于postgreSQL的系统表含义以及如何查表相关信息,但是都没有一个完整的内容,所以自己将找到的一些内容作了下整合,大家可以根据自己需要再对sql进行调整. --1.查询对象 ...

  8. CSS-负边距原理

    一.负边距原理 正边距以相邻模块的位置为参考点进行移动,并对周围模块进行合理地排挤. 负边距即margin的四个边界值为负值. 在html中使用负边距margin-left和margin-top相当于 ...

  9. sqlserver负载均衡

    http://www.cnblogs.com/gaizai/p/3644510.html

  10. python 基础学习2--编程

    python编程的步骤为: __name__ 指示模块如何被加载:如果模块被导入,__name__的值是模块的名称,如果模块被直接执行,__name__的值是main 变量不用进行声明,直接赋值:无需 ...