Bzoj 2190[sdoi2008] Honor Guard

Source: Internet
Author: User

Description

As a sports Commissioner, C June is responsible for the training of the honor guard.       Guard of Honor is composed of students of N * N of the square, in order to ensure that the procession uniform, c June will follow the guard of Honor's left rear, according to the number of students in the line of sight to determine whether the team is neat (such as). Now, C-June wants you to tell him the number of students you can see when the team is neat.

Input

A total of a number n.

Output

A total of a number, that is, c June should see the number of students.

Sample Input4

Sample Output9


HINT

"Data size and conventions" for 100% of data, 1≤n≤40000

The ... Find Phi, calculate
1#include <cstdio>2 Const intmaxn=40010;3 BOOLPD[MAXN];4 intPhi[maxn],prime[maxn],top,n,ans;5 voidES () {6      for(intI=2; i<n;i++){7         if(!Pd[i]) {8prime[++top]=i;9phi[i]=i-1;Ten         } One          for(intj=1; j<=top&&prime[j]*i<=n;j++){ Apd[prime[j]*i]=1; -             if(i%prime[j]==0){ -phi[prime[j]*i]=phi[i]*Prime[j]; the                  Break; -             } -phi[prime[j]*i]=phi[i]* (prime[j]-1); -         } +     }  - } +  A intMain () { atscanf"%d",&n); - ES (); -      for(intI=1; i<n;i++) phi[i]+=phi[i-1]; -ans=phi[n-1]*2+3; -printf"%d", ans); -}

Bzoj 2190[sdoi2008] Honor Guard

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.