# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19449 | codingman | Α (kriii4_P1) | C++14 | 1000 ms | 524288 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 <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stack>
#include <string>
#include <regex>
#include <map>
#include <numeric>
using namespace std;
vector<string> s;
//string c;
long long A, X;
vector<int> Avector;
/*
첫 번째 줄에는 정수 A(1?≤?A?≤?10^18)이 주어진다.
두 번째 줄에는 정수 X(1?≤?X?≤?10^18)가 주어진다.
*/
int main()
{
cin >> A >> X;
long long mod = 1000000007;
//Avector.push_back(1);
long long temp = 1;
Avector.push_back(A);
//long long prevValue = A;
int cnt = 1;
while(1)
{
//if(temp >= X)
//{
// break;
//}
auto t = (Avector.back() % mod)* (Avector.back() % mod) % mod;
if(cnt > X)
break;
else
Avector.push_back(t);
cnt <<= 1;
}
long long tX = X;
vector<int> binary;
while(tX)
{
//printf("%d", tX % 2);
binary.push_back(tX % 2);
tX /= 2;
}
long long result = 1;
for(int i=0; i<binary.size(); i++)
{
if(binary[i])
{
result = (result % mod) * (Avector[i] % mod) % mod;
}
}
cout << result;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |