z需要满足的条件就是
z=2t−1
,且
t+1
是梅森素数。
梅森素数就是满足
2p−1
为素数的素数p。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
inline char gc(){
static char buf[1<<16],*S,*T;
if(S==T){T=(S=buf)+fread(buf,1,1<<16,stdin);if(S==T) return EOF;}
return *S++;
}
inline ll read(){
ll x=0,f=1;char ch=gc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc();
return x*f;
}
int mp[41] = {0,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;
inline int ksm(int x,int k){
int res=1;
for(;k;k>>=1,x=(ll)x*x%mod)
if(k&1) res=(ll)res*x%mod;return res;
}
int main(){
// freopen("a.in","r",stdin);
n=read();
printf("%d\n",(ksm(2,mp[n]-1)+mod-1)%mod);
return 0;
}