結果
| 問題 |
No.403 2^2^2
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-03-06 23:07:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 736 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 76,904 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:24:10 |
| 合計ジャッジ時間 | 1,774 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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