mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:32:00 +00:00
B3969 [GESP202403 五级] B-smooth 数
https://www.luogu.com.cn/record/174743452
This commit is contained in:
parent
c7114f4976
commit
7cd1049391
34
Luogu/B3969/B3969.cpp
Normal file
34
Luogu/B3969/B3969.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e6 + 5;
|
||||
|
||||
int n, b, a[N]{0, 1}, cnt;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> b;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (a[i] == 0) {
|
||||
for (int j = i; j <= n; j += i) {
|
||||
a[j] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
if (a[i] <= b) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << cnt << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user