結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー roiti46
提出日時 2015-12-09 00:27:29
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-09-14 20:36:26
合計ジャッジ時間 2,175 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 29 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def gcd(a, b):
    while b: a, b = b, a%b
    return a

def lcm(a, b):
    return a/gcd(a, b)*b

N = int(raw_input())
a, b, c = map(int, raw_input().split())

if b % a == 0 and c % a == 0:
    ans = N/a
elif b % a == 0:
    ans = N/a + N/c - N/lcm(a, c)
elif c % a == 0 or c % b == 0:
    ans = N/a + N/b - N/lcm(a, b)
else:
    ans = N/a + N/b + N/c - N/lcm(a,b) - N/lcm(b,c) - N/lcm(c,a) - N/lcm(lcm(a,b),c)
print ans
0