結果
問題 |
No.403 2^2^2
|
ユーザー |
![]() |
提出日時 | 2017-07-27 21:37:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 1,708 ms |
コンパイル使用メモリ | 165,416 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 02:13:29 |
合計ジャッジ時間 | 2,608 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
// 基本テンプレート (縮小版) #include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long template<typename T> void chmax(T &a, T b) {a = max(a, b);} template<typename T> void chmin(T &a, T b) {a = min(a, b);} template<typename T> void chadd(T &a, T b) {a = a + b;} typedef pair<int, int> pii; typedef long long ll; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; ll mod_pow(ll x, ll n, ll mod) { if(x == 0 && n == 0) return 0; if(n == 0) return 1; ll res = mod_pow((x * x) % mod, n / 2 , mod); if(n & 1) res = (res * x) % mod; return res; } signed main() { int A, B, C; scanf("%lld^%lld^%lld", &A, &B, &C); A %= MOD; B %= (MOD-1); // a^(p-1) ≡ a^0 (mod p) int vl = mod_pow(mod_pow(A, B, MOD), C, MOD); int vr = mod_pow(A, mod_pow(B, C, MOD-1), MOD); printf("%lld %lld\n", vl, vr); return 0; }