zoukankan      html  css  js  c++  java
  • HDU 5753 Permutation Bo

    计算每个c[i]对答案做出的贡献,累加即可。手算一下会发现是:c[1]/2+(c[2]+....c[n-1])/3+c[n]/2。注意:一个数的时候直接输出那个数。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi = acos(-1.0), eps = 1e-8;
    void File()
    {
        freopen("D:\in.txt", "r", stdin);
        freopen("D:\out.txt", "w", stdout);
    }
    inline int read()
    {
        char c = getchar();  while (!isdigit(c)) c = getchar();
        int x = 0;
        while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
        return x;
    }
    
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            if(n==1) { int x; scanf("%d",&x); printf("%d
    ",x); }
            else
            {
                double ans=0;
                for(int i=1;i<=n;i++)
                {
                    int x; scanf("%d",&x);
                    if(i==1||i==n) ans=ans+1.0*x/2;
                    else ans=ans+1.0*x/3;
                }
                printf("%lf
    ",ans);
            }
        }
        return 0;
    }
  • 相关阅读:
    动态数组arraylist的使用
    第一次
    layui.mobile.css
    index.html
    Ansible部署配置
    微服务项目配置文件
    镜像挂载
    网卡设置
    获取内存信息
    超时方法
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5710137.html
Copyright © 2011-2022 走看看