結果

問題 No.106 素数が嫌い!2
ユーザー takakintakakin
提出日時 2020-05-12 21:28:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 5,000 ms
コード長 636 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 103,560 KB
最終ジャッジ日時 2023-10-11 23:41:02
合計ジャッジ時間 5,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
89,484 KB
testcase_01 AC 76 ms
71,472 KB
testcase_02 AC 77 ms
71,700 KB
testcase_03 AC 76 ms
71,808 KB
testcase_04 AC 248 ms
89,140 KB
testcase_05 AC 443 ms
103,560 KB
testcase_06 AC 445 ms
102,788 KB
testcase_07 AC 432 ms
102,780 KB
testcase_08 AC 107 ms
77,720 KB
testcase_09 AC 105 ms
77,896 KB
testcase_10 AC 432 ms
102,984 KB
testcase_11 AC 244 ms
87,808 KB
testcase_12 AC 440 ms
101,376 KB
testcase_13 AC 74 ms
71,484 KB
testcase_14 AC 75 ms
71,484 KB
testcase_15 AC 79 ms
75,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
def primes(n):
  is_prime=[1]*(n+1)
  is_prime[0]=0
  is_prime[1]=0
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=0
  return [is_prime,[i for i in range(n+1) if is_prime[i]]]
T,P=primes(n)
ans=0
for i in range(2,n+1):
  if T[i]:
    if T[i]>=k:
      ans+=1
    continue
  else:
    for p in P:
      if i%p:
        continue
      else:
        if (i//p)%p:
          T[i]=T[i//p]+1
        else:
          T[i]=T[i//p]
        break
    if T[i]>=k:
      ans+=1
print(ans)
0