对于这个问题考点有两个,
1就是判断1~10^n这个范围内有多少个素数。
2就是如何判断位数;
对于第一个问题有一个素数定理 ::对于小于n的数素数个数为n/lnn.
对于第二个问题就是判断位数有一个公式lg(x) + 1;
所以代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pi acos(-1)
#define For(i, a, b) for(int (i) = (a); (i) <= (b); (i) ++)
#define Bor(i, a, b) for(int (i) = (b); (i) >= (a); (i) --)
using namespace std;
typedef long long ll;
const int maxn = 100 + 10;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
inline int read(){
int ret=0,f=0;char ch=getchar();
while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
return f?-ret:ret;
}
int n;
int main(){
while(cin >> n){
double m = (n - log10(n)-log10(log(10)));
cout << int(m) + 1 << endl;
}
return 0;
}