标签:tle pow accept ons eof using 降幂 mis contest
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 3245 Accepted Submission(s): 1332
1 //2017-08-04 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 #define ll long long 7 8 using namespace std; 9 10 const int N = 100010; 11 const int MOD = 1000000007; 12 char str[N]; 13 14 ll quick_pow(ll a, ll n){//快速幂 15 ll ans = 1; 16 while(n){ 17 if(n&1)ans = ans*a%MOD; 18 a = a*a%MOD; 19 n>>=1; 20 } 21 return ans; 22 } 23 24 int main() 25 { 26 while(scanf("%s", str)!=EOF){ 27 ll num = 0; 28 for(int i = 0; i < strlen(str); i++){//欧拉降幂 29 num *= 10; 30 num += str[i]-‘0‘; 31 num %= (MOD-1); 32 } 33 num -= 1; 34 printf("%lld\n", quick_pow(2, num)); 35 } 36 37 return 0; 38 }
HDU4704(SummerTrainingDay04-A 欧拉降幂公式)
标签:tle pow accept ons eof using 降幂 mis contest
原文地址:http://www.cnblogs.com/Penn000/p/7287338.html