# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19553 | inspire12 | Α (kriii4_P1) | C++98 | 0 ms | 1208 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 <cstdio>
#include <vector>
using namespace std;
vector<pair<long long, long long> > v;
unsigned long long res = 1;
int main() {
long long n;
long long m;
long long i;
unsigned long long temp;
pair<long long, long long> p;
long long num = 0;
scanf("%lld", &n);
scanf("%lld", &m);
p.first = n;
p.second = 1;
v.push_back(p);
temp = n;
for (i = 2; i <= m; i *= 2) {
p.first = (temp * temp) % 1000000007;
temp = ( temp * temp )% 1000000007;
p.second = i;
v.push_back(p);
} long long a;
while(!v.empty() && m>0){
a = v[v.size() - 1].second;
if(m- a>=0) res = ((res % 1000000007) * (v[v.size()-1].first % 1000000007)) % 1000000007, m-= a;
v.pop_back();
} printf("%lld", res % 1000000007);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |