結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー yumechi
提出日時 2015-12-08 20:52:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 488 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 53,696 KB
最終ジャッジ日時 2024-11-21 11:12:25
合計ジャッジ時間 2,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
    if a < b:
        a,b = b,a
    while b > 0:
        r = a % b
        a,b = b,r
    return a

def lcm(a, b):
    if a == 0 or b == 0:
        print("Error")
        return 0
    return int(a * b // gcd(a, b))

def calc(N, li):
    ret = 0
    a, b, c = li

    ret += N // a + N // b + N // c;
    ret -= N // lcm(a, b) + N // lcm(b, c) + N // lcm(c, a);
    ret += N // lcm(a, lcm(b, c));

    return ret

print(calc(int(input()), [int(i) for i in input().split()]))
0