Task: | Exponentiation |
Sender: | bielaltes |
Submission time: | 2024-11-16 19:24:28 +0200 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:5:24: warning: multi-character character constant [-Wmultichar] 5 | const long long MOD = 1'000'000'007; | ^~~~~ input/code.cpp:5:32: warning: missing terminating ' character 5 | const long long MOD = 1'000'000'007; | ^ input/code.cpp:5:32: error: missing terminating ' character 5 | const long long MOD = 1'000'000'007; | ^~~~~ input/code.cpp:5:24: error: expected ',' or ';' before '\x303030' 5 | const long long MOD = 1'000'000'007; | ^~~~~ input/code.cpp: In function 'int main()': input/code.cpp:31:17: error: 'fastpow' was not declared in this scope 31 | cout << fastpow(as[i], bs[i]) << endl; | ^~~~~~~
Code
#include <bits/stdc++.h> using namespace std; const long long MOD = 1'000'000'007; long long fastpow(long long x, long long n) { if (n == 0) return 1; if (n & 1 == 1) return x * fastpow(x, n-1) % MOD; long long halfpow = fastpow(x, n/2); return halfpow*halfpow % MOD; } int main() { int n; cin >> n; vector<long long> as(n), bs(n); for (int i = 0; i < n; i++) { cin >> as[i]; cin >> bs[i]; } for (int i = 0; i < n; i++) { cout << fastpow(as[i], bs[i]) << endl; } return 0; }