結果
問題 |
No.2043 Ohuton and Makura
|
ユーザー |
👑 ![]() |
提出日時 | 2022-05-05 21:21:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 499 ms / 2,000 ms |
コード長 | 1,584 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 80,484 KB |
最終ジャッジ日時 | 2024-09-20 03:06:31 |
合計ジャッジ時間 | 6,680 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
def Smallest_Prime_Factor(N): """ 0,1,2,...,N の最小の素因数のリスト (0,1 については 1 にしている) """ if N==0: return [1] N=abs(N) L=list(range(N+1)) L[0]=L[1]=1 x=4 while x<=N: L[x]=2 x+=2 x=9 while x<=N: if L[x]==x: L[x]=3 x+=6 x=5 Flag=0 while x*x<=N: if L[x]==x: y=x*x while y<=N: if L[y]==y: L[y]=x y+=x<<1 x+=2+2*Flag Flag^=1 return L def Faster_Prime_Factorization(N,L): """ Smallest_Prime_Factors(N)で求めたリストを利用して, N を高速素因数分解する. L: Smallest_Prime_Factors(N)で求めたリスト """ if N==0: return [[0,1]] elif N>0: D=[] else: D=[[-1,1]] N=abs(N) while N>1: a=L[N] k=0 while L[N]==a: k+=1 N//=a D.append([a,k]) return D def Divisors_from_Prime_Factor(P,sorting=False): X=[1] for p,e in P: q=1 n=len(X) for _ in range(e): q*=p for j in range(n): X.append(X[j]*q) if sorting: X.sort() return X #================================================== A,B,S=map(int,input().split()) L=Smallest_Prime_Factor(S) Ans=0 for s in range(1,S+1): D=Faster_Prime_Factorization(s,L) for a in Divisors_from_Prime_Factor(D): b=s//a Ans+=max(0,A-a+1)*max(0,B-b+1) print(Ans)