poj 4014 Dice 贪心
//poj 4014
//sep9
#include <iostream>
#include <algorithm>
using namespace std;
int n;
struct DICE
{
int ids;
int num;
int a[128];
}d[1024]; int cmp1(DICE x,DICE y)
{
return x.num<y.num;
} int cmp2(DICE x,DICE y)
{
return x.ids<y.ids;
}
int main()
{
scanf("%d",&n);
int sum=0;
double ans=0;
for(int i=1;i<=n;++i){
scanf("%d",&d[i].num);
sum+=d[i].num;
d[i].ids=i;
}
sort(d+1,d+1+n,cmp1);
for(int i=1;i<=n;++i)
for(int j=1;j<=d[i].num;++j){
d[i].a[j]=sum--;
ans+=d[i].a[j]*1.0/d[i].num;
}
sort(d+1,d+1+n,cmp2);
printf("%.5lf\n",ans);
for(int i=1;i<=n;++i){
for(int j=1;j<=d[i].num;++j)
printf("%d ",d[i].a[j]);
printf("\n");
}
return 0;
}
poj 4014 Dice 贪心的更多相关文章
- POJ 1456(贪心)
#include <string.h> #include <iostream> #include <queue> #include <stdio.h> ...
- poj -3614 Sunscreen(贪心 + 优先队列)
http://poj.org/problem?id=3614 有c头奶牛在沙滩上晒太阳,每头奶牛能忍受的阳光强度有一个最大值(max_spf) 和最小值(min_spf),奶牛有L种防晒霜,每种可以固 ...
- POJ 3614 Sunscreen 贪心
题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 to avoid ...
- POJ 1456 - Supermarket - [贪心+小顶堆]
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarke ...
- poj 3404&&poj1700(贪心)
Bridge over a rough river Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4143 Accept ...
- poj 2287(贪心)
Tian Ji -- The Horse Racing Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 12490 Acc ...
- poj 2431 Expedition 贪心 优先队列 题解《挑战程序设计竞赛》
地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪 ...
- poj 2431 Expedition 贪心
简单的说说思路,如果一开始能够去到目的地那么当然不需要加油,否则肯定选择能够够着的油量最大的加油站加油,,不断重复这个贪心的策略即可. #include <iostream> #inclu ...
- poj 3154 Graveyard 贪心
//poj 3154 //sep9 #include <iostream> #include <cmath> using namespace std; double a[204 ...
随机推荐
- 深入浅出-网络七层模型&&网络数据包
网络基本概念 OSI模型 OSI 模型(Open System Interconnection model)是一个由国际标准化组织
- 平时常用的Visual Studio操作技巧,持续更新中……
移除未使用的命名空间--方法1:右键--"组织using"--"移除未使用的using"--方法2:Shift+F10--"O"-" ...
- 转 iOS开发debug跟release版本log屏蔽方法
简单介绍以下几个宏: ) __VA_ARGS__ 是一个可变参数的宏,这个可变参数的宏是新的C99规范中新增的,目前似乎只有gcc支持(VC6.0的编译器不支持).宏前面加上##的作用在于,当可变参数 ...
- Android Gradle Plugin指南(四)——測试
原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing 5.Testing(測试) 构建一个測试 ...
- mysql数据库字符集初步理解
1.MySQL(4.1以后版本) 服务器中有六个关键位置使用了字符集的概念,他们是: 1.client 2.connection 3.database 4.results 5.server 6.sys ...
- 阿里云96页报告详解《云上转型》(10个案例、10大趋势/完整版PPT)
阿里云96页报告详解<云上转型>(10个案例.10大趋势/完整版PPT) 2017-12-29 14:20阿里云/云计算/技术 ﹃产业前沿超级干货﹄ ﹃数据观○重磅速递﹄ 阿里云研究中心云 ...
- csv2txt.cpp
#include <iostream> #include <fstream.h> #include <windows.h> #include <iomanip ...
- strdup实现
char * strdup(char *str) { char * strNew; assert(str != NULL); strNew = (); strcpy(strNew,str); retu ...
- error: 'release' is unavailable: not available in automatic reference counting,该怎么解决
编译出现错误: 'release' is unavailable: not available in automatic reference counting mode.. 解决办法: You nee ...
- OTL使用指南
1 OTL简介 OTL 是 Oracle, Odbcand DB2-CLI Template Library 的缩写,是一个C++编译中操控关系数据库的模板库,它目前几乎支持当前所有的各种主流数据库, ...