Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3440 Accepted Submission(s): 1408
Problem Description
![](https://i-blog.csdnimg.cn/blog_migrate/2fb92eb08283067dc96500ff89a997ed.jpeg)
Sample Input
2
Sample Output
2Hint1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cases.
Source
Recommend
zhuyuanchen520
/*
隔板法推出答案为2^(n-1)%(1e9+7)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
const long long mod=1e9+7;
char s[maxn];
LL quickpow(LL x,LL a){
LL ans=1;
while(a){
if(a&1)
ans=ans*x%mod;
x=x*x%mod;
a>>=1;
}
return ans;
}
int main()
{
while(~scanf("%s",s)){
int len=strlen(s);
LL phi=mod-1;
LL n=0;
for(int i=0;i<len;i++)
n=(n*10+s[i]-'0')%phi;
n=(n-1+phi)%phi+phi;
printf("%I64d\n",quickpow(2,n));
}
return 0;
}