結果
問題 |
No.403 2^2^2
|
ユーザー |
![]() |
提出日時 | 2017-06-09 02:04:32 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 781 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 22,016 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 13:38:22 |
合計ジャッジ時間 | 1,161 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 4 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:47:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%lld^%lld^%lld",&a,&b,&c); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> typedef long long int ln; int phi(int n){ int res=1; if(n%2==0){ n/=2; while(n%2==0){ res*=2; n/=2; } } int k=3; while(k*k<=n){ if(n%k==0){ res*=k-1; n/=k; while(n%k==0){ res*=k; n/=k; } } k+=2; } if(n>1){ res*=n-1; } return res; } int modPow(ln r,ln n,int mod){ r=r%mod; n=n%phi(mod); ln res=1; ln t=r; while(n>0){ res=res*(n&0x01?t:1)%mod; t=t*t%mod; n>>=1; } return res; } void run(void){ ln a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c); const int p=1000000007; int a_bc=modPow(a,b%(p-1)*(c%(p-1)),p); int b_c=modPow(b,c,p-1); int a_b_c=modPow(a,b_c,p); printf("%d %d\n",a_bc,a_b_c); return; } int main(void){ run(); return 0; }