bzoj2190: [SDOI2008] Honor Guard

Source: Internet
Author: User

Sieve the Euler function and you can do it.

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace STD; #define REP (i,s,t) for (int i=s;i<=t;i++) #define CLR (x,c) memset (x,c,sizeof (x)) const int Nmax=40005;int Phi[nmax ],prime[nmax];bool vis[nmax];void init () {    phi[1]=1;int cnt=0;    Rep (i,2,nmax-1) {        if (!vis[i]) prime[++cnt]=i,phi[i]=i-1;        Rep (j,1,cnt) {            int x=prime[j];            if (I*x>=nmax) break;            Vis[i*x]=1;            if (i%x==0) {                phi[i*x]=phi[i]*x;break;            } else phi[i*x]=phi[i]*phi[x];        }    }    Rep (i,1,100) printf ("%d", Phi[i]);p rintf ("\ n");} int main () {    init ();    int ans=0,n;scanf ("%d", &n);    Rep (i,1,n-1) ans+=phi[i];    printf ("%d\n", ans*2+1);    return 0;}

  

2190: [SDOI2008] Honor guard Time limit:10 Sec Memory limit:259 MB
submit:2560 solved:1631
[Submit] [Status] [Discuss] 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

Source [Submit] [Status] [Discuss]

bzoj2190: [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.