nefu117 素数个数的位数 素数定理+位数公式
这道题目 看着很吓人,完全没法入手,后来才知道是个简单题,首先是 球位数,那肯定跟位数公式有关,再是素数,最后找了一下素数定理,先贴一下关于 素数定理的 资料
http://baike.baidu.com/link?url=eTwkODHWsxXk-thQCi0swy4DAKRYUBBGBM__mQIL4NoCJhmlsst33yETUOA7WQiG
#include<iostream>根据素数定理,随着x的增长π(x)与 x/lnx,最后几乎相等,所以本道题目直接球 x/lnx的位数即可,再根据位数公式 那么 ln(x/lnx)+1就是最后的答案,对于ln(x/lnx)是要进行化简的 化简结果在代码中给出
#include<cstdio>#include<list>#include<algorithm>#include<cstring>#include<string>#include<queue>#include<stack>#include<map>#include<vector>#include<cmath>#include<memory.h>#include<set>#define ll long long#define LL __int64#define eps 1e-8#define e 2.718281828////const ll INF=9999999999999;#define M 400000100#define inf 0xfffffffusing namespace std;//vector<pair<int,int> > G;//typedef pair<int,int> P;//vector<pair<int,int>> ::iterator iter;////map<ll,int>mp;//map<ll,int>::iterator p;////vector<int>G[30012];int main(void){double x;while(cin>>x){double ans=double(x-log10(x)-log10(log(10.0)));//这是上述式子变形过来的结果cout<<int(ans)+1<<endl;//注意int的转化,我被坑了 好几把}}