結果
| 問題 |
No.415 ぴょん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-24 17:44:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 1,000 ms |
| コード長 | 580 bytes |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-02 20:44:43 |
| 合計ジャッジ時間 | 1,832 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
def gcd(*numbers: int) -> int:
if len(numbers) == 1:
return numbers[0]
if len(numbers) == 2:
a, b = numbers
if a < b:
a, b = b, a
while True:
if a % b == 0:
return b
a, b = b, a % b
first_gcd = gcd(*numbers[:2])
return gcd(first_gcd, *numbers[2:])
def main():
N, D = map(int, input().split())
ND_gcd = gcd(N, D)
N, D = N // ND_gcd, D // ND_gcd
if N % D == 0:
print(N // D - 1)
else:
print(N - 1)
if __name__ == "__main__":
main()