zoukankan      html  css  js  c++  java
  • BZOJ-2190 [SDOI2008]仪仗队

    数论。。。

    答案就是前n-1个欧拉函数的总和再*2+1

    #include <cstdlib>
    #include <cstdio>
    #include <cstring>
    #include <cctype>
    #include <cmath>
    #include <algorithm>
    #include <iostream>
    #define rep(i, l, r) for(int i=l; i<=r; i++)
    #define clr(x, c) memset(x, c, sizeof(x))
    #define maxn 45678
    using namespace std;
    inline int read()
    {
    	int x=0, f=1; char ch=getchar();
    	while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    	while (isdigit(ch)) x=x*10+ch-'0', ch=getchar();
    	return x*f;
    }
    int f[maxn];
    int main()
    {
    	int n=read()-1, ans=0; 
    	rep(i, 1, n) f[i]=i;
    	rep(o, 2, n) if (f[o]==o) for(int i=o; i<=n; i+=o) f[i]=f[i]/o*(o-1);
    	rep(i, 1, n) ans+=f[i]; 
    	if (!n) printf("0
    "); else printf("%d
    ", ans*2+1);
    	return 0;
    }
  • 相关阅读:
    5-29
    5-28
    5-27
    -5-26
    5-25
    5-24
    5-21
    RabbitMQ消息中间件极速入门与实战
    细说java多线程之内存可见性
    全面解析java注解
  • 原文地址:https://www.cnblogs.com/NanoApe/p/4479902.html
Copyright © 2011-2022 走看看