結果
| 問題 |
No.106 素数が嫌い!2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-21 20:36:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 5,000 ms |
| コード長 | 579 bytes |
| コンパイル時間 | 1,751 ms |
| コンパイル使用メモリ | 163,032 KB |
| 実行使用メモリ | 18,852 KB |
| 最終ジャッジ日時 | 2025-06-21 20:36:53 |
| 合計ジャッジ時間 | 2,776 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void solve(){
int N,K; cin>>N>>K;
vector<int> p(N+1,-1);
for(int i=2;i<=N;++i){
for(int j=i;j<=N;j+=i){
if(p[j]==-1){
int x=j;
while(x%i==0) x/=i;
p[j]=x;
}
}
}
vector<int> f(N+1,-1);
f[1]=0;
int ans=0;
for(int i=2;i<=N;++i){
f[i]=f[p[i]]+1;
if(f[i]>=K) ans++;
}
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1; //cin>>t;
for(;t--;) solve();
}