2171-Help Chef Gerasim ZCMU

Description

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.

题意:chef Gerasim 总是给所有的杯子倒入相同体积的果汁,但总有人恶作剧把果汁从一杯倒入另一杯,chef Gerasim要求你找出是哪两杯果汁。如果所有果汁体积相同 输出"Exemplary pages.",如果恰好有两杯果汁互倒,且原先的体积与其他果汁一致,输出"v ml. from cup #a to cup #b.",如果有两杯以上的果汁体积不同,输出"Unrecoverable configuration."

代码:

#include<stdio.h>
#include<math.h>
int main()
{
    int cup[1005],ave;
    int i,c,n,index1,index2;
    while(~scanf("%d",&n))
    {
        ave=0;
        for(i=0;i<n;i++)
        {
          scanf("%d",&cup[i]);
          ave+=cup[i];
        }
        if(ave%n!=0)
        {
            printf("Unrecoverable configuration.\n");
            continue;
        }
        c=0; ave/=n;
        for(i=0;i<n;i++)
        {
            if(ave!=cup[i])
                c++;
        }
        if(c==0)
            printf("Exemplary pages.");
        else if(c>2)
            printf("Unrecoverable configuration.");
        else if(c==2)
        {
            index1=index2=-1;
            for(i=0;i<n;i++)
            {
                if(cup[i]!=ave)
                {
                    if(index1==-1)
                        index1=i;
                    else
                        index2=i;
                }
                if(index1!=-1&&index2!=-1)
                    break;
            }
            if(cup[index1]>cup[index2])
              printf("%d ml. from cup #%d to cup #%d.",cup[index1]-ave,index2+1,index1+1);
            else
              printf("%d ml. from cup #%d to cup #%d.",cup[index2]-ave,index1+1,index2+1);
        }
        printf("\n");
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/zcmu_2024/article/details/81157582