codeforces 225E 梅森素数

xiaoxiao2021-02-28  76

题解: ACdreamer orz!

code:

#include <cstdio> #include <cstring> using namespace std; typedef long long ll; const ll p = 1e9 + 7; ll a[] ={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 FastPowMod(ll a, ll b){ ll ret = 1 % p; while(b){ if(b & 1) ret = ret * a % p; a = a * a % p; b >>= 1; } return ret; } int main(){ // freopen("in.txt", "r", stdin); int n; scanf("%d", &n); printf("%lld\n", (FastPowMod(2, a[n] - 1) + p - 1) % p); return 0; }
转载请注明原文地址: https://www.6miu.com/read-79284.html

最新回复(0)