# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19458 | codingman | Α (kriii4_P1) | C++14 | 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 <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;
unsigned long long A, X;
vector<unsigned long long> Avector;
/*
첫 번째 줄에는 정수 A(1?≤?A?≤?10^18)이 주어진다.
두 번째 줄에는 정수 X(1?≤?X?≤?10^18)가 주어진다.
*/
int main()
{
cin >> A >> X;
unsigned long long mod = 1000000007;
//Avector.push_back(1);
unsigned long long temp = 1;
Avector.push_back(A);
//long long prevValue = A;
unsigned long long 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;
}
unsigned long long tX = X;
vector<int> binary;
while(tX)
{
//printf("%d", tX % 2);
binary.push_back(tX % 2);
//cout << tX % 2 << endl;
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... |