Title Address: Nefu 117
Test instructions: Give you an integer N (n<1e9), and if the number of primes in an integer less than 10^n is π (n), the number of digits of π (n) is obtained.
Idea: The data volume of the topic is very large, directly seek affirmation tle, so consider the prime number theorem.
Prime theorem: Remember that π (N) is a number of <=n, then there are
A number of digits X can be used LG (x) + one, so the subject of LG (N/INN) +1 is the request, because n=10^n, so the number of bits =LG (10^n)-lg (in (10^n)) +1=n-lgn-lg (in (10)) +1.
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#include <bitset>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef Long LongLL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-7;Const intmaxn=1e6+Ten;intMain () {DoubleN,m; while(~scanf("%LF", &n)) {m= (nlog10(n)-log10(Log(Ten)));printf("%d\n",(int) m+1); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Nefu 117-Number of primes (prime number theorem)