結果
| 問題 |
No.106 素数が嫌い!2
|
| コンテスト | |
| ユーザー |
けーむ
|
| 提出日時 | 2020-03-26 11:28:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,242 bytes |
| コンパイル時間 | 1,951 ms |
| コンパイル使用メモリ | 169,008 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2025-01-02 01:08:30 |
| 合計ジャッジ時間 | 36,366 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
map<ll, ll> factorize2(ll n) {
map<ll, ll> res;
for (ll i = 2; (i * i) <= n; i++) {
if (n % i) continue;
res[i] = 0;
while((n % i) == 0) {
n /= i;
res[i]++;
}
}
if (n != 1) res[n] = 1;
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
ll n, k;
cin >> n >> k;
ll ans = 0;
vector<bool> checked(n + 1, false);
reps(i, 2, n + 1) {
if (checked[i]) continue;
auto fac = factorize2(i);
if (sz(fac) >= k) {
for(ll j = i; j <= n; j += i) {
if (checked[j]) continue;
checked[j] = true;
ans++;
}
}
}
cout << ans << endl;
return 0;
}
けーむ