結果
| 問題 |
No.403 2^2^2
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-03-06 22:54:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 717 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 77,024 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 00:44:08 |
| 合計ジャッジ時間 | 1,882 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
constexpr int P = 1000000007;
int64_t powll(int64_t n, int64_t k, int mod = P) {
int64_t r = 1, t = n % mod;
for (; k != 0; k /= 2) {
if (k & 1) r = r * t % mod;
t = t * t % mod;
}
return r;
}
int main() {
string s;
cin >> s;
auto i = s.find('^');
auto j = s.find('^', i + 1);
int64_t a, b, c;
a = stoll(s.substr(0, i));
b = stoll(s.substr(i + 1, j));
c = stoll(s.substr(j + 1));
cout << powll(powll(a, b), c) << ' ' << powll(a, powll(b, c, P - 1)) << endl;
return 0;
}
merom686