Untitled---------------Constructors

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.