結果

問題 No.316 もっと刺激的なFizzBuzzをください
コンテスト
ユーザー brthyyjp
提出日時 2020-04-26 06:17:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 404 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 138 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 54,784 KB
最終ジャッジ日時 2026-05-10 15:35:40
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#import fractions
import math
from functools import reduce
def lcm_base(x, y):
  #return (x * y) // fractions.gcd(x, y)
  return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

ans = n//a + n//b + n//c
ans -= n//lcm_base(a, b) + n//lcm_base(b, c) + n//lcm_base(c, a)
ans += n//lcm_list([a, b, c])

print(ans)
0