Judging Olympia

Time Limit: 1000MS Memory limit: 65536K

题目描述

 For years, a group of Regional Contest Directors (RCDs) of the ACM International Collegiate  Programming Contest (ICPC) have been unsatisfied with the way contest submissions get ranked.  The group sees it is academically wrong to emphasize the importance of program correctness, disregarding the “quality” of the program itself. After all, programming as a profession promotes design, style, maintainability, etc. and not just correctness. The group’s suggestion is to have a panel of six judges. Each judge is assigned the task of grading the submissions based on a particular aspect: 1) Correctness; 2) Robustness; 3) Overall design; 4) Clarity; 5) Coding style; and finally 6) Maintainability. The final grade of a submission would be the average of the six grades it gets. 
The old guards of the current ICPC judging style have always responded that it is not possible to impartially judge a program on anything but correctness. How can the ICPC be certain that judging is fair? In other words, how can the ICPC be sure that non of the judges is favoring certain teams and disadvantaging others? Any hint of accusation to the judging process and ICPC loses the prestigious status it worked on for years. (Alright! So they do have a point.) Still, this hasn’t stopped other domains from judging candidates based on subjective metrics. Take for example Gymnastics, or The Nobel Prizes, or even the ACM’s very own Doctoral Dissertation Award.  These are all highly respected awards where the winner is selected by judges using subjective metrics. ICPC could use a new judging system based on what is used in gymnastics. Rather than having each judge grade a certain aspect of the program, each of the six judges would assign an overall grade (out of ten) based on all of the six metrics mentioned above. To enforce impartiality, the final grade of a submission would be calculated as the average of all the grades after deleting two grades: The highest and the lowest. Any judge that favors a certain team (and assigns them an undeserved high grade,) risks the possibility of that grade being dismissed. Similarly, any judge that attempts to disadvantage a team by assigning them a low grade faces a similar risk.  Write a program to print the final grade of a submission. 

输入

 Your program will be tested on one or more test cases. Each test case is described on a single input line listing the grades of the judges. The end of the test cases is identified with a dummy test case with all the grades being zero.
 

输出

 For each test case, print the grade on a separate line (without unnecessary decimal points and/or zeros.)
 

示例输入

8 8 8 4 4 4
8 8 6 4 4 3
0 0 0 0 0 0

示例输出

6
5.5


代码:

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<sstream>
using namespace std;
int main()
{
    double a[7];
    double sum=0;
    while(true)
    {
        sum=0;
        for(int i=0;i<6;i++)
        {
            scanf("%lf",&a[i]);
            sum+=a[i];
        }
        if(sum==0)
        break;
        sort(a,a+6);
        sum=sum-a[0]-a[5];
        printf("%d",(int)(sum/4.0));
        int summ=(int)((sum/4.0)*1000000);
        int b[10];
        //printf("%d\n",summ);
        for(int i=0;i<6;i++)
        {
            b[i]=summ%10;
            summ=summ/10;
        }
        int flag=0;
        for(int i=5;i>=0;i--)
        {
            if(b[i]!=0)
            {
                if(flag==0)
                {
                    printf(".%d",b[i]);
                    flag=1;
                }
                else
                printf("%d",b[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

题目:

Hide That Number

Time Limit: 1000MS Memory limit: 65536K

题目描述

According to Wikipedia, Cryptography is “the practice and study of hiding information” and this is exactly what Alex is looking for. Ever since he was a kid, Alex was paranoid over someone laying their hands on his phone book. He decided that he must write the numbers in some secret way that only he can decipher. At first he tried quite complex algorithms, but that slowed him down when he needed to dial a number fast. He finally came up with the following algorithm: Rather than writing down the number itself, Alex would shift the number one place to the left (as if multiplying it by 10,) then adding the shifted number to the original. For example, if the phone number was 123, Alex would add 1230 to it, resulting in 1353. To make what he writes looks as a regular phone number, Alex truncates the result (from the left,) so that it has as many digits as the original phone number. In this example, Alex writes 353 instead of 123 in his phone book.
Alex needs a program to print the original phone number given what is written in his phone book.  Alex, who by the way is a good friend of Johnny, isn’t that good in arithmetic. It is quite possible that the numbers are messed up. The program should print "IMPOSSIBLE" (without the quotes) if the original number cannot be computed.
 

输入

 Your program will be tested on one or more test cases. Each case is specified on a separate line and is made of a single positive number having less than 1, 000, 000 digits. The last line of the input file is made of a single zero.
 

输出

For each test case, output the result on a single line using the following format:
k._result
Where k is the test case number (starting at 1) and _ is a single space.
 
 

示例输入

353
9988
123456
0

示例输出

1. 123
2. IMPOSSIBLE
3. 738496
代码:

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char a[10000005];
int ans[10000005];
int cas;
int main()
{
    cas=1;
    while(scanf("%s",a))
    {
        if(a[0]=='0')
            break;
        int len=strlen(a);
        ans[len]=0;
        for(int i=len-1; i>=0; i--)
        {
            ans[i]=a[i]-'0'-ans[i+1];
            if(ans[i]<0)
            {
                ans[i]+=10;
                if(i-1>=0)
                a[i-1]=a[i-1]-'0'-1+'0';
            }
        }
//        for(int i=0;i<len;i++)
//        {
//            printf("%d",ans[i]);
//        }cout<<endl;
        printf("%d. ",cas++);
        if(ans[0]<=0)
        {
            printf("IMPOSSIBLE\n");
        }
        else
        {
            for(int i=0; i<len; i++)
            {
                printf("%d",ans[i]);
            }
            printf("\n");
        }
    }
    return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值