結果
問題 | No.403 2^2^2 |
ユーザー |
👑 |
提出日時 | 2019-05-02 11:52:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 809 bytes |
コンパイル時間 | 960 ms |
コンパイル使用メモリ | 72,884 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-31 13:18:25 |
合計ジャッジ時間 | 1,968 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:35:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%lld^%lld^%lld", &a, &b, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdlib> #include <cstddef> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <iostream> #include <iomanip> #define L64 long long #define MOD (1000000007LL) L64 modpow(L64 src, L64 pow, L64 mod) { L64 res = 1; while (0 < pow) { if (pow % 2 == 1) { res = (res * src) % mod; pow--; } src = (src * src) % mod; pow /= 2; } return res; } L64 modinv(L64 src, L64 mod) { return modpow(src, mod - 2, mod); } int main(void) { L64 a, b, c; scanf("%lld^%lld^%lld", &a, &b, &c); L64 r1 = modpow(a % MOD, b, MOD); r1 = modpow(r1, c, MOD); L64 r2 = modpow(b % (MOD - 1LL), c, MOD - 1LL); if(r2 == 0LL){ r2 = MOD - 1LL; } r2 = modpow(a % MOD, r2, MOD); std::cout << r1 << " " << r2 << std::endl; }