博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5753 Permutation Bo
阅读量:6902 次
发布时间:2019-06-27

本文共 987 字,大约阅读时间需要 3 分钟。

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

#pragma comment(linker, "/STACK:1024000000,1024000000")#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
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\n",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\n",ans); } } return 0;}

 

转载于:https://www.cnblogs.com/zufezzt/p/5710137.html

你可能感兴趣的文章
Druid Kafka indexing service (上篇 )
查看>>
界面控件Essential Studio for ASP.NET Web Forms 2017 v3发布丨附下载
查看>>
谷歌宣布为Android 9.0用户提供云端加密
查看>>
8.12 tee_tr_split命令
查看>>
gzip bzip2 xz 压缩工具
查看>>
Windriver for linux安装
查看>>
HTTP协议学习# request 和response 解析(转)
查看>>
Linux学习-0918
查看>>
Redis在mac上的安装
查看>>
Jmeter
查看>>
持续优化云原生体验,阿里云在Serverless容器与多云上的探索
查看>>
java 多进程
查看>>
还没写过爬虫的小白点进来,一文带你入门python爬虫(小白福利)
查看>>
【synchronized底层原理之3】JDK1.6对锁所做的优化
查看>>
重写equals方法时重写hashcode方法的必要性
查看>>
Mybatis 缓存系统源码解析
查看>>
20180825 上课截图
查看>>
深入解析Vue里函数的调用顺序介绍
查看>>
Ember.js 入门指南——model的关联关系处理
查看>>
Ubuntu Linux下使用搜狗浏览器加速代理
查看>>