結果

問題 No.982 Add
ユーザー 💕💖💞
提出日時 2020-04-02 13:52:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-28 15:01:47
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())

def factorization(n):
    ret = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            ret.add(i)
    if temp!=1:
        ret.add(temp)
    if len(ret)==0:
        ret.add(n)
    return ret

a = factorization(A)
b = factorization(B)

if len(a & b) != 0:
    print(-1)
    exit()
    
N = A * B

print((A-1)*(B-1)//2)
0