結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー imulan
提出日時 2016-02-10 01:38:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 433 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-21 12:17:54
合計ジャッジ時間 2,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(x,y):
    if x<y :
        x,y=y,x

    while y!=0:
        x,y=y,x%y

    return x

def lcm(x,y):
    return x*y//gcd(x,y)

def solve():
    n=int(input())
    a,b,c=map(int,input().split())

    ct_a=n//a
    ct_b=n//b
    ct_c=n//c

    ct_ab=n//lcm(a,b)
    ct_bc=n//lcm(b,c)
    ct_ca=n//lcm(c,a)

    ct_abc=n//lcm(a,lcm(b,c))

    print(ct_a+ct_b+ct_c-ct_ab-ct_bc-ct_ca+ct_abc)

if __name__ == "__main__":
    solve()
0