# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19331 |
2016-02-24T09:53:21 Z |
pang |
Α (kriii4_P1) |
C++14 |
|
1000 ms |
1716 KB |
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
#define MOD 1000000007
long long value(int n, int a)
{
long long r = 1;
long long cnt = (1 << n);
//cout << cnt << endl;
while (cnt--)
{
r *= a;
r = r%MOD;
}
return r;
}
int main()
{
long long x, a;
cin >> a;
cin >> x;
string s;
while (x > 0)
{
s += '0' + (x & 1);
x >>= 1;
}
reverse(s.begin(), s.end());
int l = s.length();
long long int ans = 1;
//cout << s << endl;
for (int i = 0; i < l; i++)
{
int input = l - i-1;
if (s[i] == '1')
{
ans *= value(input, a);
ans = ans%MOD;
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
1716 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |