# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19336 | pang | Α (kriii4_P1) | C++98 | 0 ms | 1720 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
#define MOD 1000000007
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++)
{
ans *= ans;
ans = ans%MOD;
if (s[i] == '1')
{
ans *= a;
ans = ans%MOD;
}
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |