# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
19368 | golala123 | Α (kriii4_P1) | C++98 | 0 ms | 1720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
long long a, x;
long long ans = 1;
int temp = 1;
vector<long long> m;
vector< pair<int , int > > two;
const int MOD = 1000000007;
int main(){
cin >> a >> x;
a %= MOD;
x %= MOD;
int temp = 1;
int i = 0;
m.push_back(a);
while (temp <= x){
long long aa = 1;
aa = m[i]%MOD * m[i]%MOD;
aa %= MOD;
m.push_back(aa%MOD);
temp *= 2;
i++;
}
int j = 0;
while (x != 0){
if (x%2 == 1)
two.push_back({ j, x % 2 });
x /= 2;
j++;
}
for (int i = 0; i < two.size(); i++){
if (two[i].second == 1){
ans = ans*m[two[i].first] % MOD;
ans %= MOD;
}
}
cout << ans % MOD;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |