NEFU 117

可以用素数定理来解决。

素数定理:小于n的素数个数记为p(n),则随着n的增长,p(n)/(n/ln(n))=1。

#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	double n;
	while(scanf("%lf",&n)!=EOF){
		int ans=(int)n-log10(n*log(10));
		ans++;
		printf("%d
",ans);
	}
	return 0;
}

  

原文地址:https://www.cnblogs.com/jie-dcai/p/3940162.html