結果
| 問題 | No.982 Add |
| コンテスト | |
| ユーザー |
komkompi
|
| 提出日時 | 2020-03-29 13:03:37 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 66 ms / 2,000 ms |
| + 228µs | |
| コード長 | 577 bytes |
| 記録 | |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2026-10-13 11:14:32 |
| 合計ジャッジ時間 | 2,726 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#最大公約数
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