Poj 3090 & amp; poj 2478 (farei series, Euler's function)

Source: Internet
Author: User
Tags acos

Poj 3090 & amp; poj 2478 (farei series, Euler's function)

 

 

The recurrence formula of the faray series is very simple: f [1] = 2; f [I] = f [I-1] + phi [I].

This is the deformation of the farei series. The answer is 2 * f [I]-1.

 

# Include
 
  
# Include
  
   
# Include
   # Include
    
     
# Include
     
      
# Include
      
        # Include
       
         # Include
        
          # Include
         
           # Include
          
            # Include
           
             # Include # define LL long # define _ LL _ int64 # define eps 1e-12 # define PI acos (-1.0) using namespace std; const int maxn = 1100; int flag [maxn]; int prime [maxn]; int phi [maxn]; LL f [maxn]; void init () {memset (flag, 0, sizeof (flag); prime [0] = 0; phi [1] = 1; for (int I = 2; I <maxn; I ++) {if (flag [I] = 0) {phi [I] = I-1; prime [++ prime [0] = I;} for (int j = 1; j <= prime [0] & prime [j] * I
            
             

 

Http://poj.org/problem? Id = 2478

It is simpler to directly calculate the repeat series. Euler's Function Based on prime screening.

 

#include 
              
               #include 
               
                #include
                #include 
                 
                  #include 
                  
                   #include 
                   
                    #include 
                    
                     #include 
                     
                      #include 
                      
                       #include 
                       
                        #include 
                        
                         #include #define LL long long#define _LL __int64#define eps 1e-12#define PI acos(-1.0)using namespace std;const int maxn = 1000010;int flag[maxn];int prime[maxn];int phi[maxn];LL f[maxn];void init(){memset(flag,0,sizeof(flag));prime[0] = 0;phi[1] = 1;for(int i = 2; i < maxn; i++){if(flag[i] == 0){phi[i] = i-1;prime[++prime[0]] = i;}for(int j = 1; j <= prime[0]&&prime[j]*i
                         
                          

 

 

 

Related Article

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.