z = (x/2)取整后 + y + xy,x,y都是大于0的整数。
z=[x2]+y+xy
x,y取不同的数,z可能有多种表示方式,也可能一种都没有,比如3,15就无法用任何x,y来表示。现在将所有无法表示的数排个序,组成一个序列S,给出一个整数n,你来求Snn = ?。比如n = 1,Snn = 1,n = 2,Snn = 3……,由于Snn可能很大,只输出 mod 1000000007 的结果即可。
Input
输入一个数N(1 <= n <= 40)。
Output
输出Snn % 10^9 + 7的结果。
Sample Input
3
Sample Output
15
梅森素数
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
const int MOD = 1000000007;
typedef long long LL;
LL p[] ={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,24036583,25964951};
LL quick_mod(LL a,LL b,LL m)
{
LL ans = 1;
a %= m;
while(b)
{
if(b&1)
{
ans = ans * a % m;
b--;
}
b >>= 1;
a = a * a % m;
}
return ans;
}
int main()
{
int n;
while(~scanf("%d",&n))
{
LL ans = quick_mod(2,p[n]-1,MOD);
ans = (ans - 1 + MOD) % MOD;
printf("%I64d\n",ans);
}
return 0;
}