Chain the Ropes
来源:互联网 发布:mac tower 使用教程 编辑:程序博客网 时间:2024/06/11 22:37
题目描述:https://www.patest.cn/contests/pat-a-practise/1125
#include <iostream>#include <algorithm>using namespace std;#define MAX 10010int main (){ int n,i; int j; double num[MAX]; cin>>n; for( i=0;i<n;++i) { scanf("%lf",&num[i]); } sort(num,num+n); for( i=0;i<n-1;++i ) { double a = num[i],b = num[i+1]; num[i+1] = a/2 + b/2; //cout<<a/2 + b/2<<endl; //sort(num+i+1,num+n); 不用每次都排序,二分之一之后数变得更小了,直接插入就行了// /** for(j=i+1;j<n;++j) { if( j==n-1 ) cout<<num[j]<<"***"<<endl; else cout<<num[j]<<" "; } */ } printf("%d\n",(int)num[n-1]); return 0;}
0 0
- Chain the Ropes
- 1125. Chain the Ropes (25)
- PAT--1125. Chain the Ropes
- 1125. Chain the Ropes 解析
- PAT A1125 Chain the Ropes
- 1125. Chain the Ropes (25)
- 1125. Chain the Ropes (25)
- 1125. Chain the Ropes (25)
- 1125. Chain the Ropes (25)
- 1125. Chain the Ropes (25)
- PAT 1125. Chain the Ropes (25)-甲级
- PAT 1125. Chain the Ropes (25)
- pat 甲1125. Chain the Ropes (贪心)
- PAT A1125. Chain the Ropes (25)(哈夫曼树)
- PAT_A 1125. Chain the Ropes (25)
- PAT甲级.1125. Chain the Ropes (25)
- PAT甲级 1125. Chain the Ropes (25)
- PAT 甲级 1125. Chain the Ropes (25)
- jenkins持续集成配置
- xxx的纠错(1)
- 深入浅出Redis-Spring整合Redis
- 【POJ 3259】Wormholes
- centos7 修复win10引导
- Chain the Ropes
- win10系统安装oracle11g时遇到INS-13001环境不满足最低要求
- CUDA Sample 求和
- 适配器模式
- 【Maven】在Eclipse中使用Maven
- 防止asp马后门
- Apache Struts2(S2-045)漏洞利用
- PTA 5-16 朋友圈 (25分)【并查集】
- HBase的RIT