結果
| 問題 |
No.403 2^2^2
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 28,288 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-20 21:08:33 |
| 合計ジャッジ時間 | 983 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | int a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#define int long long
using namespace std;
const int M=1e9+7,P=1000000013000000042; bool flag;
int mul(int a,int b,int p) {
int ans=0;
while(b) {
if(b&1) {
ans+=a;
if(ans>=p) flag=true,ans%=p;
}
(a+=a)%=p,b>>=1;
}
return ans;
}
int power(int a,int b,int p) {
int ans=1;
while(b) {
if(b&1) ans=mul(ans,a,p);
a=mul(a,a,p),b>>=1;
}
return ans;
}
signed main() {
int a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c);
printf("%lld ",power(power(a,b,M),c,M));
flag=false; int k=power(b,c,P)+P*flag;
printf("%lld",power(a,k,M));
return 0;
}
lam6er