zoukankan      html  css  js  c++  java
  • BZOJ 2190 (欧拉函数)

    2190: [SDOI2008]仪仗队

    Description

      作为体育委员,C君负责这次运动会仪仗队的训练。仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是否整齐(如下图).现在,C君希望你告诉他队伍整齐时能看到的学生人数。

    Input

      共一个数N。

    Output

      共一个数,即C君应看到的学生人数。

    Sample Input

      4

    Sample Output

      9
     
     1 #include<cstdio>
     2 #include<iostream>
     3 #include<queue>
     4 #include<map>
     5 #include<cstring>
     6 #include<algorithm>
     7 using namespace std;
     8 typedef long long ll;
     9 typedef unsigned long long ull;
    10 const int N=40005;
    11 int phi[N];
    12 int sum[N];
    13 void phi_table()
    14 {
    15     for(int i=2;i<N;i++)
    16         phi[i]=0;
    17     phi[1]=1;
    18     for(int i=2;i<N;i++)
    19         if(!phi[i])
    20         {
    21             for(int j=i;j<N;j+=i)
    22             {
    23                 if(!phi[j])phi[j]=j;
    24                 phi[j]=phi[j]/i*(i-1);
    25             }
    26         }
    27 }
    28 int main()
    29 {
    30     phi_table();
    31     for(int i=1;i<N;i++)
    32         sum[i]=sum[i-1]+phi[i];
    33     int n;
    34     while(scanf("%d",&n)!=EOF)
    35     {
    36         if(n==1){puts("0");continue;}
    37         printf("%d
    ",sum[n-1]*2+1);
    38     }
    39     return 0;
    40 }
  • 相关阅读:
    linux 硬件信息
    docker note
    Shell cmd set note
    mysql management note
    scp noneed passwd
    update kernel
    数据包处理过程
    tcp/ip分片
    sockopt note
    Python note
  • 原文地址:https://www.cnblogs.com/homura/p/5280519.html
Copyright © 2011-2022 走看看