Submission #19553

#TimeUsernameProblemLanguageResultExecution timeMemory
19553inspire12Α (kriii4_P1)C++98
0 / 100
0 ms1208 KiB
#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 timeMemoryGrader output
Fetching results...