結果
問題 | No.181 A↑↑N mod M |
ユーザー | yaoshimax |
提出日時 | 2015-05-09 12:19:31 |
言語 | PyPy2 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 876 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 77,744 KB |
実行使用メモリ | 81,040 KB |
最終ジャッジ日時 | 2023-09-19 09:26:56 |
合計ジャッジ時間 | 23,820 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 490 ms
80,280 KB |
testcase_01 | AC | 484 ms
80,564 KB |
testcase_02 | AC | 484 ms
80,620 KB |
testcase_03 | AC | 485 ms
80,440 KB |
testcase_04 | AC | 483 ms
80,664 KB |
testcase_05 | AC | 482 ms
80,408 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 487 ms
80,524 KB |
testcase_10 | AC | 486 ms
80,628 KB |
testcase_11 | AC | 482 ms
80,348 KB |
testcase_12 | AC | 488 ms
80,588 KB |
testcase_13 | AC | 483 ms
80,564 KB |
testcase_14 | AC | 489 ms
80,912 KB |
testcase_15 | AC | 484 ms
80,560 KB |
testcase_16 | AC | 485 ms
80,568 KB |
testcase_17 | AC | 487 ms
80,548 KB |
testcase_18 | AC | 486 ms
80,300 KB |
testcase_19 | AC | 487 ms
80,696 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 490 ms
80,252 KB |
testcase_23 | WA | - |
testcase_24 | AC | 487 ms
80,668 KB |
testcase_25 | AC | 487 ms
80,512 KB |
testcase_26 | AC | 487 ms
80,696 KB |
testcase_27 | AC | 487 ms
80,680 KB |
testcase_28 | WA | - |
testcase_29 | AC | 489 ms
80,404 KB |
testcase_30 | AC | 487 ms
80,560 KB |
testcase_31 | AC | 487 ms
80,296 KB |
testcase_32 | AC | 487 ms
80,600 KB |
testcase_33 | AC | 485 ms
80,604 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 492 ms
80,408 KB |
testcase_38 | WA | - |
testcase_39 | AC | 486 ms
80,408 KB |
testcase_40 | AC | 485 ms
80,504 KB |
testcase_41 | WA | - |
testcase_42 | AC | 487 ms
80,524 KB |
ソースコード
def gcd(i,j): if j<i: return gcd(j,i) if j%i==0: return i else: return gcd(j%i,i) def getint(i): ret=0 for j in range(i-1,0,-1): if gcd(j,i)==1: ret+=1 return ret interval=[getint(i) for i in range(0,2001)] def getExpWithUpperBound(A,N,M): if N==0: return min(1,M) if N==1: return min(A,M) if N==2 and A<=16: return min(pow(A,A),M) if N==3 and A<=3: return min(pow(A,pow(A,A)),M) if N==4 and A<=2: return min(pow(A,pow(A,pow(A,A))),M) else: return M def hypermod(A,N,M): if N==0: return 1 if M==1: return 0 e=getExpWithUpperBound(A,N-1,M) if e<M: return pow(A,e,M) else: return pow(A,hypermod(A,N-1,interval[M]),M) A,N,M=map(int,raw_input().split()) print hypermod(A,N,M)