結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
komkompi
|
| 提出日時 | 2020-03-29 13:03:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 115 ms / 2,000 ms |
| コード長 | 577 bytes |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-01-02 13:22:33 |
| 合計ジャッジ時間 | 2,430 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#最大公約数
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
#最小公倍数
def lcm(a,b):
return a*b//gcd(a,b)
A,B=map(int,input().split())
if A==1 or B==1:
print(0)
exit()
Al=[]
for i in range(1,int(A**0.5)+1):
if A/i==A//i:
Al.append(i)
Al.append(A//i)
#print(Al)
for item in Al[1:]:
if B%item==0:
print(-1)
exit()
eu=(lcm(A,B))
ans=0
for num in range(1,eu):
org=num
while num>-1:
if num%B==0:
ans+=1
break
else:
num-=A
print(eu-ans-1)
komkompi