結果
| 問題 | No.403 2^2^2 |
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-03-06 23:07:40 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 338µs | |
| コード長 | 736 bytes |
| 記録 | |
| コンパイル時間 | 406 ms |
| コンパイル使用メモリ | 95,868 KB |
| 実行使用メモリ | 9,792 KB |
| 最終ジャッジ日時 | 2026-09-02 01:53:09 |
| 合計ジャッジ時間 | 1,947 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#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) << ' ' << (a % P == 0 ? 0 : powll(a, powll(b, c, P - 1))) << endl;
return 0;
}
merom686