【欧拉降幂公式+快速幂】HDU_4704_Sum

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
 

Sample Input
 
   
2
 

Sample Output
 
   
2
Hint
1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cases.
 

Source
2013 Multi-University Training Contest 10
 

Recommend
zhuyuanchen520
 
/*
隔板法推出答案为2^(n-1)%(1e9+7)
*/
#include 
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

你可能感兴趣的:(欧拉定理)