結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー FromBooskaFromBooska
提出日時 2023-02-27 22:10:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 1,000 ms
コード長 503 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 71,708 KB
最終ジャッジ日時 2023-10-13 06:37:34
合計ジャッジ時間 4,537 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,468 KB
testcase_01 AC 71 ms
71,476 KB
testcase_02 AC 69 ms
71,288 KB
testcase_03 AC 62 ms
71,680 KB
testcase_04 AC 60 ms
71,324 KB
testcase_05 AC 58 ms
71,372 KB
testcase_06 AC 62 ms
71,676 KB
testcase_07 AC 68 ms
71,372 KB
testcase_08 AC 62 ms
71,248 KB
testcase_09 AC 66 ms
71,372 KB
testcase_10 AC 64 ms
71,292 KB
testcase_11 AC 65 ms
71,680 KB
testcase_12 AC 60 ms
71,148 KB
testcase_13 AC 61 ms
71,324 KB
testcase_14 AC 59 ms
71,412 KB
testcase_15 AC 61 ms
71,324 KB
testcase_16 AC 60 ms
71,384 KB
testcase_17 AC 61 ms
71,376 KB
testcase_18 AC 62 ms
71,472 KB
testcase_19 AC 63 ms
71,412 KB
testcase_20 AC 61 ms
71,244 KB
testcase_21 AC 63 ms
71,372 KB
testcase_22 AC 61 ms
71,388 KB
testcase_23 AC 63 ms
71,168 KB
testcase_24 AC 62 ms
71,548 KB
testcase_25 AC 63 ms
71,684 KB
testcase_26 AC 63 ms
71,412 KB
testcase_27 AC 61 ms
71,292 KB
testcase_28 AC 62 ms
71,708 KB
testcase_29 AC 60 ms
71,292 KB
testcase_30 AC 64 ms
71,292 KB
testcase_31 AC 63 ms
71,352 KB
testcase_32 AC 60 ms
71,372 KB
testcase_33 AC 61 ms
71,528 KB
testcase_34 AC 62 ms
71,176 KB
testcase_35 AC 63 ms
71,244 KB
testcase_36 AC 64 ms
71,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 包除原理、ビット全探索
# Algo X Math ID068

N = int(input())
abc = list(map(int, input().split()))
K = 3

from math import gcd

ans = 0 
for bit in range(1<<K):
    if bit == 0:
        continue
    count = 0
    LCM = 1
    for shift in range(K):
        if bit>>shift & 1 == 1:
            count += 1
            LCM = LCM*abc[shift]//gcd(LCM, abc[shift])
    if count%2 == 1:
        ans += N//LCM
    else:
        ans -= N//LCM
    #print(bin(bit), count, LCM, N//LCM, ans)

print(ans)
0