結果

問題 No.106 素数が嫌い!2
ユーザー nanaenanae
提出日時 2017-01-08 19:16:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,028 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 10,520 KB
実行使用メモリ 62,176 KB
最終ジャッジ日時 2023-08-22 17:41:52
合計ジャッジ時間 11,868 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
15,824 KB
testcase_01 AC 15 ms
7,904 KB
testcase_02 AC 16 ms
7,836 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 1,231 ms
44,936 KB
testcase_05 AC 1,645 ms
27,060 KB
testcase_06 AC 1,554 ms
23,656 KB
testcase_07 AC 1,545 ms
23,584 KB
testcase_08 AC 145 ms
13,096 KB
testcase_09 AC 108 ms
9,132 KB
testcase_10 AC 1,621 ms
23,556 KB
testcase_11 AC 649 ms
14,948 KB
testcase_12 AC 2,028 ms
62,176 KB
testcase_13 AC 16 ms
7,772 KB
testcase_14 AC 15 ms
7,740 KB
testcase_15 AC 16 ms
7,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.106 素数が嫌い!2

N, K = map(int, input().split())

dp = [0 for i in range(N + 1)]

if K == 1:
    print(N - 2 + 1)
else:
    ans = 0

    for i in range(2, (N + 1) // 2 + 1):
        if dp[i] == 0:
            for j in range(i, N + 1, i):
                dp[j] += 1

                if dp[j] >= K:
                    ans += 1
                    dp[j] = -N

    print(ans)
0