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. hdu 5207 BestCoder Round #38 ($) Greatest Greatest Common Divisor

    #include<stdio.h> #include<string.h> #include<math.h> ]; ]; int main() { int sb; s ...

  2. 解决ie 低版本的 background-size 兼容问题

    在IE不支持这个属性的时候可以通过滤镜来实现这样的一个效果. div{background-size: cover;filter:progid:DXImageTransform.Microsoft.A ...

  3. java 的对象拷贝(有深浅拷贝两种方式,深拷贝实现的两种方式(逐层实现cloneable接口,序列化的方式来实现))

    Java提高篇--对象克隆(复制)(转自:http://www.cnblogs.com/Qian123/p/5710533.html#_label0)   阅读目录 为什么要克隆? 如何实现克隆 浅克 ...

  4. windows上安装ubuntukylin16.04并且在ubuntukylin上安装jdk

    1.安装ubuntukylin16.04 教程链接:http://jingyan.baidu.com/article/f71d60379824041ab641d19d.html 我是完全按照这个教程来 ...

  5. 数数字(Digit Counting,ACM/ICPC Danang 2007,UVa1225)

    #include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char s[10000]; in ...

  6. oAuth 使得第三方无需使用用户的用户名与密码就可以申请获得该用户资源的授权

    OAUTH协议为用户资源的授权提供了一个安全的.开放而又简易的标准.与以往的授权方式不同之处是OAUTH的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需使用用户的用户名与密码就可 ...

  7. javaWEB总结(11):JSP简介及原理

    前言 本文主要通过一个简单小例子,介绍JSP的原理. 1.项目结构 2.web.xml <?xml version="1.0" encoding="UTF-8&qu ...

  8. Major and minor numbers

    The major nuber is the driver associated with the device, while the minor number is used by the kern ...

  9. Dubbo.xml配置源-Dubbo.xsd分析

      我们使用Dubbo时,一般都会使用xml配置基本信息,如项目名称(application).注册中心(register).协议(protocal).服务(service),如下所示: 1 2 3 ...

  10. Chapter 2 Open Book——23

    Mike interrupted us then — he was planning an epic battle of the blizzard in the parking lot after s ...