沐枫NOI 6. Help Chef Gerasim 模拟

该问题描述了一个遥远王国的厨师Gerasim怀疑年轻侍者们在准备国王餐桌时调换了果汁。他发现每个杯子里的果汁量可能经过了转移。任务是编写一个程序,确定是否只进行了一次果汁倒转,如果可以,指出倒了多少毫升从哪个杯子到哪个杯子。输入包含杯子数量和每个杯子的果汁量,输出可能是确认没有倒果汁、一次倒转的具体信息或无法恢复的配置信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

5
270
250
250
230
250

Output

20 ml. from cup #4 to cup #1.

Input

5
250
250
250
250
250

Output

Exemplary pages.

Input

5
270
250
249
230
250

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");
		}
		else
		if(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]);
			else
			printf("%d ml. from cup #%d to cup #%d.\n",abs(b[0]-fz),++index[0],++index[1]);
		}
		else printf("Unrecoverable configuration.\n");
	}
	return 0;
} 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值