結果

問題 No.2043 Ohuton and Makura
ユーザー 👑 KazunKazun
提出日時 2022-05-05 21:21:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 510 ms / 2,000 ms
コード長 1,584 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 80,156 KB
最終ジャッジ日時 2023-10-20 07:35:47
合計ジャッジ時間 7,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,488 KB
testcase_01 AC 38 ms
53,488 KB
testcase_02 AC 329 ms
78,440 KB
testcase_03 AC 320 ms
78,224 KB
testcase_04 AC 437 ms
79,464 KB
testcase_05 AC 350 ms
78,448 KB
testcase_06 AC 129 ms
76,600 KB
testcase_07 AC 469 ms
79,700 KB
testcase_08 AC 151 ms
76,644 KB
testcase_09 AC 332 ms
78,592 KB
testcase_10 AC 424 ms
79,340 KB
testcase_11 AC 324 ms
78,448 KB
testcase_12 AC 35 ms
53,488 KB
testcase_13 AC 498 ms
80,156 KB
testcase_14 AC 36 ms
53,488 KB
testcase_15 AC 35 ms
53,488 KB
testcase_16 AC 38 ms
53,488 KB
testcase_17 AC 484 ms
80,020 KB
testcase_18 AC 510 ms
79,968 KB
testcase_19 AC 472 ms
79,964 KB
testcase_20 AC 475 ms
79,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0