沐枫NOI 6. Help Chef Gerasim 模拟
来源:互联网 发布:sql setup.exe打不开 编辑:程序博客网 时间:2024/06/08 07:40
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
Input
The first line contains integer n − the number of cups on the royal table (1≤n≤1000). Next n lines contain volumes of juice in each cup − non-negative integers, not exceeding 104.
Output
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
Examples
Input
5270250250230250
Output
20 ml. from cup #4 to cup #1.
Input
5250250250250250
Output
Exemplary pages.
Input
5270250249230250
Output
Unrecoverable configuration.
模拟
#include<iostream>#include<cstdio>#include<algorithm>#include<vector>#include<cmath>using namespace std;int main(){int n;scanf("%d",&n);int sum=0;int a[1000+10];for(int i=0;i<n;i++){scanf("%d",&a[i]);sum+=a[i];}int fz=sum/n;int b[10]={0},cnt=0;int index[10]={0};int flag=0;for(int i=0;i<n;i++){if(a[i]!=fz) {flag=1;break;}}if(!flag){cout<<"Exemplary pages."<<endl;}else{for(int i=0;i<n;i++){if(a[i]!=fz){index[cnt]=i;b[cnt++]=a[i];if(cnt>2) break;}}if(cnt==3) {printf("Unrecoverable configuration.\n");}elseif(b[0]+b[1]==2*fz){if(b[0]>b[1])printf("%d ml. from cup #%d to cup #%d.\n",abs(b[0]-fz),++index[1],++index[0]);elseprintf("%d ml. from cup #%d to cup #%d.\n",abs(b[0]-fz),++index[0],++index[1]);}else printf("Unrecoverable configuration.\n");}return 0;}
- 沐枫NOI 6. Help Chef Gerasim 模拟
- B. Help Chef Gerasim
- 沐枫NOI 7. Help Far Away Kingdom
- zoj 3778 Talented Chef 模拟
- 8.12NOI(P)模拟
- 【NOI 2015模拟】总结
- 7.6 NOI模拟总结
- 【NOI模拟】维护队列
- chef
- chef
- ZOJ 3778 Talented Chef(计算器模拟)
- 2014.8.12 Noi(p)模拟
- 5.19NOI模拟赛1
- 5.26NOI模拟赛2
- 【NOI 2016模拟6.16】gene
- NOI 模拟试题(一)
- NOI 模拟试题(二)
- NOI 模拟试题(三)
- 727. Minimum Window Subsequence
- 对conda和pip的一点认识
- 创建Hello world 网页服务
- dpdk加速网络协议栈ANS用户手册
- 如何写一个RPC框架(四):网络通信之客户端篇
- 沐枫NOI 6. Help Chef Gerasim 模拟
- CodeForces
- Mark一下
- python matplotlib从文件中读取数据绘制散点图
- windows通过putty连接虚拟机中的ubuntu系统
- 纯CSS画基本图形(圆形、三角形、多边形、爱心、八卦)
- 学生信息系统之优化(一)
- 去除Eslint验证
- 多线程下载apk并安装