結果
| 問題 |
No.106 素数が嫌い!2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-13 11:42:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 1,498 ms |
| コンパイル使用メモリ | 168,440 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-05 11:03:50 |
| 合計ジャッジ時間 | 29,126 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 4 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;cin >> n >> k;
int ans=0;
vector<bool> b(n+1);
for(int i=2;i<=n;i++){
if(b[i]){
ans++;
continue;
}
int num=i;
int cnt=0;
for(int j=2;j*j<=i;j++){
bool f=false;
while(num%j==0){
num/=j;
f=true;
}
if(f){
cnt++;
}
}
if(num!=1){
cnt++;
}
if(cnt>=k){
ans++;
b[i]=true;
for(int j=2;j*i<=n;j++){
b[i*j]=true;
}
}
}
cout << ans << endl;
}