可以用筛选法打表.
然后对结果排序,再二分查找.
#include <iostream>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 1000010;
int tb[maxn], m;
void init(){
int idx = 0;
for (int i = 2; i <= 1000000; ++i){
tb[i - 1] += 1;
for (int j = 2; j * i < maxn; ++j){
tb[i * j - 1] += i;
}
}
}
int main(){
init();
sort(tb, tb + 1000000);
while (~scanf("%d", &m)){
int ans = upper_bound(tb, tb + 1000000,m) - tb;
printf("%d\n",ans);
}
return 0;
}