Title Description
BobGot aAliceThe gift was very happy and studied more numbers.BobThink a numberX is graceful when and only if there is a positive integerAand a> 1 positive integers b, making x = A^b < Span class= "Mord mathit mtight".
Bob < Span class= "Mord mathit" > like to count these beautiful numbers when it's okay, but bo b has limited computational power if the numbers are too big to come out. Now he wants you to help him figure out 1< Span class= "Strut bottom" > to n< The number of spans class= "Mord mathit" > is graceful.
Input/output format
Input format:
One line is a positive integer N, as described in title.
Output format:
A row of an integer anS, representing the number of graceful numbers in 1 1 to N.
Input and Output Sample input example # #:
10
Sample # # of output:
4
Description
There are 1, 4, 8, 9 within 1 0 of the graceful.
The data for 30% satisfies 1 ≤ n ≤ 10 < Span class= "Sizing reset-size6 size3 mtight" >5.
The data for 70% satisfies 1 ≤ n ≤ 10 < Span class= "Sizing reset-size6 size3 mtight" >10.
The data for 100% satisfies 1 ≤ N ≤ 1018.
100-minute Procedure:
< Span class= "Mord" > < Span class= "vlist-t" > 1.
< Span class= "Mord" > < Span class= "vlist-t" > 2. For a contributing X, we use all x = A λb to represent it in the largest form of B.
< Span class= "Mord" > < Span class= "vlist-t" > 3. The definition function g (b) indicates how many x can be represented as a λb. The function f (b) indicates how many x can be expressed as aλb, and B satisfies the above properties.
< Span class= "Strut bottom" > < Span class= "Mord mtight" > 4. Obviously the and of the F function is the answer.
< Span class= "Strut bottom" > < Span class= "Mord mtight" > 5. G function: Pow (n, 1/b).
/span>
< Span class= "Strut bottom" > < Span class= "Mord mtight" > 6. The method of the f function: g (b)-σi | b f (i).
1#include <bits/stdc++.h>2 #definell Long Long3 using namespacestd;4ll n,f[ -],ans;5 intMain ()6 {7scanf"%lld",&n);8 for(intI= -; i>=2;--i)9 {Tenf[i]= (LL) POW (n,1.0/i)-1; One for(intj=i+i;j<= -; j+=i) Af[i]-=F[j]; -ans+=F[i]; - } theprintf"%lld", ans+1); - return 0; -}
Code
Untitled---------------Constructors