UVa 10820 (play table, Euler function) Send a table

Source: Internet
Author: User

Test instructions

The background of the topic is omitted, it is easy to translate the problem into, give N, n the number of ordered pairs (x, y) of the logarithm of the mutual pigment.

Analysis:

Problems can also continue to be transformed.

According to symmetry, we can assume that x<y, when x=y, satisfies only the conditions (1, 1).

Set F (n) as the set s{(x, y) | x<y and X, Y for the number of reciprocal, then the answer is 2f (n) +1

An F (n) expression is:

, where φ (n) is the Euler function

Here are some introduction to Euler's functions

1#include <cstdio>2 3 Const intMAXN =50000;4 5 intPHI[MAXN +Ten], SUM[MAXN +Ten];6 7 voidPhi_table (intN)8 {9phi[1] =0;Ten      for(inti =2; I <= MAXN; ++i)if(!phi[i])//description I is prime number One     { A          for(intj = i; J <= Maxn; J + =i) -         { -             if(!phi[j]) phi[j] =J; thePHI[J] = phi[j]/I * (i-1); -         } -     } - } +  - intMain () + { A phi_table (MAXN); atsum[1] = phi[1]; -      for(inti =2; I <= MAXN; ++i) Sum[i] = sum[i-1] +Phi[i]; -      -     intN; -      while(SCANF ("%d", &n) = =1&& N) printf ("%d\n",2*sum[n]+1); -      in     return 0; -}
code June

UVa 10820 (play table, Euler function) Send a table

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.