結果
問題 |
No.106 素数が嫌い!2
|
ユーザー |
|
提出日時 | 2018-01-23 20:27:30 |
言語 | cLay (20241019-1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 750 bytes |
コンパイル時間 | 2,242 ms |
コンパイル使用メモリ | 178,052 KB |
実行使用メモリ | 18,068 KB |
最終ジャッジ日時 | 2024-07-05 12:55:59 |
合計ジャッジ時間 | 14,257 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 12 |
ソースコード
void gen_primelist(vector<int>& out, ll high) { out.resize(high + 1); out[0] = out[1] = 1; ll sqh = (ll)sqrt(high); for (ll i = 2; i <= sqh; i++) { if (out[i] == 0) { for (ll j = i*i; j <= high; j += i) { // i*i out[j] = 1; } } } } vector<int> isc,pl,memo; int count(int x) { if (memo[x]) return memo[x]; for (int p:pl){ if (x%p==0) return memo[x]=count(x/p)+1; if (x==p) break; } return memo[x]=1; } { ll N,K;rd(N,K); gen_primelist(isc,N+1); pl.reserve((ll)sqrt(N)); REP(i,N+1) if(!isc[i]) pl.push_back(i); memo.resize(N+1); ll cnt=0; REP(i,N-1) cnt+=count(N-i)>=K; wt(cnt); }