結果
問題 | No.2798 Multiple Chain |
ユーザー | vwxyz |
提出日時 | 2024-06-28 22:23:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 2,387 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 82,516 KB |
実行使用メモリ | 75,952 KB |
最終ジャッジ日時 | 2024-06-28 22:23:19 |
合計ジャッジ時間 | 3,512 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
54,528 KB |
testcase_01 | AC | 36 ms
54,400 KB |
testcase_02 | AC | 38 ms
54,656 KB |
testcase_03 | AC | 39 ms
54,400 KB |
testcase_04 | AC | 39 ms
54,016 KB |
testcase_05 | AC | 39 ms
54,656 KB |
testcase_06 | AC | 39 ms
54,144 KB |
testcase_07 | AC | 40 ms
54,272 KB |
testcase_08 | AC | 39 ms
54,528 KB |
testcase_09 | AC | 41 ms
54,272 KB |
testcase_10 | AC | 41 ms
54,016 KB |
testcase_11 | AC | 44 ms
54,656 KB |
testcase_12 | AC | 41 ms
54,272 KB |
testcase_13 | AC | 37 ms
54,528 KB |
testcase_14 | AC | 38 ms
54,912 KB |
testcase_15 | AC | 37 ms
54,656 KB |
testcase_16 | AC | 37 ms
54,656 KB |
testcase_17 | AC | 48 ms
54,528 KB |
testcase_18 | AC | 37 ms
54,528 KB |
testcase_19 | AC | 36 ms
54,656 KB |
testcase_20 | AC | 36 ms
54,272 KB |
testcase_21 | AC | 36 ms
54,144 KB |
testcase_22 | AC | 48 ms
54,272 KB |
testcase_23 | AC | 34 ms
54,528 KB |
testcase_24 | AC | 35 ms
54,016 KB |
testcase_25 | AC | 37 ms
54,528 KB |
testcase_26 | AC | 37 ms
56,064 KB |
testcase_27 | AC | 36 ms
54,528 KB |
testcase_28 | AC | 37 ms
57,344 KB |
testcase_29 | AC | 35 ms
54,144 KB |
testcase_30 | AC | 37 ms
54,912 KB |
testcase_31 | AC | 35 ms
54,912 KB |
testcase_32 | AC | 64 ms
75,776 KB |
testcase_33 | AC | 48 ms
70,912 KB |
testcase_34 | AC | 66 ms
75,952 KB |
testcase_35 | AC | 37 ms
54,528 KB |
testcase_36 | AC | 49 ms
72,704 KB |
testcase_37 | AC | 37 ms
54,528 KB |
testcase_38 | AC | 41 ms
65,536 KB |
testcase_39 | AC | 37 ms
56,064 KB |
testcase_40 | AC | 36 ms
54,656 KB |
testcase_41 | AC | 35 ms
54,656 KB |
testcase_42 | AC | 36 ms
54,528 KB |
testcase_43 | AC | 36 ms
54,820 KB |
testcase_44 | AC | 35 ms
54,844 KB |
testcase_45 | AC | 47 ms
54,272 KB |
testcase_46 | AC | 35 ms
54,400 KB |
testcase_47 | AC | 36 ms
54,272 KB |
testcase_48 | AC | 35 ms
54,528 KB |
testcase_49 | AC | 34 ms
54,272 KB |
testcase_50 | AC | 35 ms
54,272 KB |
testcase_51 | AC | 35 ms
54,528 KB |
testcase_52 | AC | 45 ms
71,168 KB |
testcase_53 | AC | 37 ms
54,656 KB |
ソースコード
import math from collections import defaultdict def Miller_Rabin_Primality_Test(N): if N==1: return False NN=N-1 NN=NN//(NN&-NN) if N<4759123141: lst=[2,7,61] elif N<341550071728321: lst=[2,3,5,7,11,13,17] else: lst=[2,3,5,7,11,13,17,19,23,29,31,37] if N in lst: return True for a in lst: n=NN p=pow(a,n,N) if p==1: continue while p!=N-1: p=p*p%N if p==1 or n==N-1: return False n<<=1 return True def Pollard_Rho(N): if N==1: return None if Miller_Rabin_Primality_Test(N): return None m=1<<N.bit_length()//8 for c in range(1,99): f=lambda x:(x**2+c)%N y,r,q,g=2,1,1,1 while g==1: x=y for _ in range(r): y=f(y) k=0 while k<r and g==1: ys=y for _ in range(min(m,r-k)): y=f(y) q=q*abs(x-y)%N g=math.gcd(q,N) k+=m r<<=1 if g==N: g=1 while g==1: ys=f(ys) g=math.gcd(abs(x-ys),N) if g<N: return g def Factorize_Pollard_Rho(N): stack=[N] factorize=defaultdict(int) while stack: x=stack.pop() p=Pollard_Rho(x) if p==None: factorize[x]+=1 continue stack.append(p) stack.append(x//p) return factorize def Divisors_Pollard_Rho(N): factorize=Factorize_Pollard_Rho(N) divisors=[1] for p,e in factorize.items(): prev=divisors divisors=[] pow_p=1 for _ in range(e+1): for d in prev: divisors.append(d*pow_p) pow_p*=p divisors.sort() return divisors C=[1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015, 31185, 37338, 44583, 53174, 63261, 75175, 89134, 105558, 124754, 147273, 173525,204226,239943,281589,329931,386155,451276,526823,614154,715220,831820,966467,1121505,1300156,1505499,1741630] N=int(input()) ans=1 for p,e in Factorize_Pollard_Rho(N).items(): ans*=C[e] print(ans)