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. magento产品批量导出导入

    magento产品批量导出导入 博客分类: WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra ExcelMobile配置管理XML ...

  2. Apache 2.4.16、PHP5.6.11安装教程

    以前我写过Apache2.4和php5.5的安装教程,但是后来我自己跟着自己写的东西做时发现有很多问题,这里把这些问题重新修正,再写一个教程,供大家参考. 注意:WinXP系统请选择旧版本Apache ...

  3. cshtml一二

    布局页:_MyLayout.cshtml <!DOCTYPE html> @*Razor布局页*@ <html> <head> @*HTTP的头部协议,提示浏览器网 ...

  4. 避免VMware P2V 过程中遇到的磁盘问题及解决 版本5.5

    正式步骤开始:填写红色框内相关要被转换成虚拟机的物理机器的账号信息 选择虚拟主机要转换到的目的主机,填写相关的账号信息 设置转换参数:这里要注意一下关于磁盘的设置,注意:如果源系统是LVM的磁盘卷不将 ...

  5. docker openvswitch网络方案

    1. 测试环境 75机(10.11.150.75):Red Hat Enterprise Linux Server 7.0,无外网访问权限,已安装Docker Server 74机(10.11.150 ...

  6. TheFifthWeekText

    类的构造方法是当创建对象时,对象自动调用的对对象进行初始化的方法.他没有返回值,而且构造方法名与类名是相同的.如果类中没有定义构造方法,Java编译器在编译时会自动给它提供一个没有参数的默认构造方法, ...

  7. 【HELLO WAKA】WAKA iOS客户端 之一 APP分析篇

    由于后续篇幅比较大,所以调整了内容结构. 全系列 [HELLO WAKA]WAKA iOS客户端 之一 APP分析篇 [HELLO WAKA]WAKA iOS客户端 之二 架构设计与实现篇 [HELL ...

  8. django+celery+rabitmq

    django 项目中的设置(proj代表项目目录) proj settings.py CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672/' ...

  9. 第二章App框架设计与重构

    response标准格式: { "isError":false, "errorType": 0, "errorMessage": " ...

  10. Activity生命周期方法调用finish后的不同表现

    今天宿舍一个哥们出去面试遇到了这个面试题:"在activity oncreate()调用finish()"生命周期是怎么样的? 我赶紧写了些demo,发现确实很有趣: packag ...