标签:codeforces 梅森素数 数学推导
给出一个等式,
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int a[45] = {2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279,2203,2281,3217,4253,4423,9689,9941,11213,
19937,21701,23209,44497,86243,110503,132049,216091,756839,859433,1257787,1398269,
2976221,3021377,6972593,13466917,20996011};
int n;
LL pp ( LL num , LL x )
{
LL ret = 1;
while ( x )
{
if ( x&1 )
{
ret *= num;
ret %= mod;
}
num *= num;
num %= mod;
x >>= 1;
}
return ret;
}
int main ( )
{
while ( ~scanf ( "%d" , &n ) )
{
printf ( "%I64d\n" , pp ( 2 , a[n-1]-1 ) -1 );
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
codeforces 225E E. Unsolvable(梅森素数+数学)
标签:codeforces 梅森素数 数学推导
原文地址:http://blog.csdn.net/qq_24451605/article/details/48290443