素数定理
分析总结:
<span style="font-size:14px;">首先呢要好好读题,要求的是什么!!!真的要好好读题!其次要求掌握素数定理:定义p(x)是小于x的素数的个数有多少,然后有p(x)/(x/lnx)=1,x越大越趋近于1,然后就是位数问题@@@@,这个问题以前搞过啊要求x的位数就是(int)logx+1呀</span>
<span style="font-size:14px;"></span>//
// main.cpp
// nefu 117 素数个数的位数
//
// Created by 张嘉韬 on 16/7/25.
// Copyright © 2016年 张嘉韬. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const double e=2.718281828459;
int main(int argc, const char * argv[]) {
int n;
while(scanf("%d",&n)!=EOF)
{
double temp=n/log10(e);
temp=log10(temp);
temp=n-temp;
int r=temp;
r=r+1;
cout<<r<<endl;
}
return 0;
}
<br /><br />