1087 Mason Number

Source: Internet
Author: User

1087 Mason Number

2003 NOIP National League popularity Group

time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingTitle Description Description

The prime number of a shape such as 2p-1 is called Mason, at which point P must also be a prime. But not necessarily, that is, if p is a prime number, 2p-1 is not necessarily a prime number. By the end of 1998, 37 Mason had been found. The biggest one is p=3021377, which has 909,526 bits. Mason number has many important applications, which are closely related to the complete number.

Task: Enter P (1000<p<3100000) from the file to calculate the number of digits of 2p-1 and the last 500 digits (expressed in decimal high precision number)

Enter a description Input Description

Only one integer P (1000<p<3100000) is included in the file

Output description Output Description

First line: Decimal high precision number 2P-1 digits.

第2-11 line: Decimal High precision number 2P-1 the last 500 digits. (output 50 bits per line, output 10 lines, less than 500 bits when the high 0)

You do not have to verify that 2p-1 and p are prime numbers.

Sample input Sample Input

1279

Sample output Sample Output

386

00000000000000000000000000000000000000000000000000

00000000000000000000000000000000000000000000000000

00000000000000104079321946643990819252403273640855

38615262247266704805319112350403608059673360298012

23944173232418484242161395428100779138356624832346

49081399066056773207629241295093892203457731833496

61583550472959420547689811211693677147548478866962

50138443826029173234888531116082853841658502825560

46662248318909188018470682222031405210266984354887

32958028878050869736186900714720710555703168729087

Data range and Tips Data Size & HintCategory labels Tags Click here to expandHigh-precision Noip National League popular Group mainland region 2003 years AC Code:
#include <cstdio>#include<iostream>#include<cmath>using namespacestd;intsta[10001], out[10001],i,n,j;voidSolveintN) {    if(n==0)return; Solve (n/2);  for(i=1; i<= -; i++)       for(j=1; j<= -; j + +)      if(n%2==0) sta[i+j-1]+= out[i]* out[j]; Elsesta[i+j-1]+= out[i]* out[j]*2;  for(i=1; i<= -; i++)      {             out[i]=sta[i]%Ten; Sta[i+1]+=sta[i]/Ten; }     for(i=1; i<= +; i++) sta[i]=0;}intMain () {CIN>>N; cout<<floor (log (2)/log (Ten) *n+1) <<Endl;  out[1]=1;    Solve (n);  for(i= -; i>=2; i--) {cout<< out[i]; if(i% -==1) cout<<Endl; } cout<< out[1]-1<<Endl; return 0;}

1087 Mason Number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.