蛋蛋的忧伤ing

题目描述

 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<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int num[6];
    double ans;
    while(1)
    {
        ans=0;
        for(int i=0; i<6; i++)
            scanf("%d",&num[i]);
        sort(num,num+6);
        if(num[5]==0)
            break;
        for(int i=1;i<5;i++)
          ans+=num[i]*1.0;
        printf("%g\n",ans/4);
    }
    return 0;
}

题目描述

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<stdio.h>
#include<string.h>
char nu[1000007];
int num[1000007],ans[1000007];
int main()
{
    int count=1;
    while(scanf("%s",nu)!=EOF)
    {
        if(strcmp(nu,"0")==0)
             break;
        int Len=strlen(nu)-1;
        ans[0]=nu[Len]-'0';
       // printf("a=%d\n",ans[0]);
        int step=1;
        for(int i=0; i<=Len; i++)
        {
            num[i]=nu[i]-'0';
        }
        for(int i=Len-1; i>=0; i--)
        {
            if(num[i]<ans[step-1])
            {
                ans[step++]=10+num[i]-ans[step-1];
                num[i-1]--;
            }
            else ans[step++]=num[i]-ans[step-1];
        }
        printf("%d. ",count++);
        if(ans[Len]==0)printf("IMPOSSIBLE\n");
        else
        {
            for(int i=Len; i>=0; i--)
                printf("%d",ans[i]);
            printf("\n");
        }
    }
    return 0;
}
 

题目描述

Us: So why don’t you just recompile the program Us: What about "ddd" and "dddd"? How does it on the new hardware? behave then?
Them: We cannot. We lost the source code. Them: Where in English will you find a "dddd" or even a "ddd"? Haven’t you been listening?
Us: How typical! What does the program do? Do you have any documentation?
Them: The manual page does mention something about the documentation in the source code.
Us: A manual page is good. What does it say?
Them: Just one line: “See the source code for more information.”
Us: Argh! What do you know about the program?
Them: Well, it seems to be taking simple text, similar to that found in an English dictionary, and printing it after some modification.
Us: What kind of modification?
Them: It removes any character that is not a lowercase letter. But not white spaces. White spaces are preserved as seen in the input.
Us: Do you have a sample input/output?
Them: Plenty. Here’s one. (see next page.)
Us: This is rather small! Did you try it on anything
bigger?
Us: Oops. We’ll pay more attention. Anything else?
Another one of them: There is also the "vv" thingy.
Us: What about "vv"?
Them: Every "vv" is replaced with a "m".Yet another one of them: No, wait! That was a printer problem. it had nothing to do with the program.
Remember?
Them: Oh, that’s right.thingy. Forget about the "vv"
Us: What about the "dd" thingy? Was that just a printer problem too?
Them: No. That was the program.
Us: What else?
Them: One last thing.every "ei" with "ie".It seems to be replacing
Us: Every one of them?
Them: Except if it comes right after "c" then it remains as is.
Them: It works on any text as long as the lines are Them: No, we just remembered one more thing: It less then eighty characters wide. It doesn’t seem replaces the sequence "pink" with "floyd" any to mind working on lengthy documents. But it where in the text.does terminate once it sees the sequence "EOF" (without the double quotes.) 
One of them: Don’t forget to tell them about the Us: What?! Who wrote this program? Why do you "dd" thingy. need it in the first place?
Us: : What "dd" thingy?
Them: We think it will increase our chances of going to Banff in April 2008 if we get it right.
Them: Whenever it sees a pair of small letter "d",one right after the other, it replaces them with "p".
Us: Makes sense. That’s all, right?
Us: Yeah! Right.
Us: Why?
Them: Who knows? It just does that!
 

输入

 

输出

 

示例输入

unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from        liechtenstein
 ..  ...adding means to imitat.#$!%%$e
EOF

示例输出

unfloyded is an  letter word onest
vv is ok dd is ok p is not
i received mail from        liechtenstien
   aping means to imitate

提示

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
    string st;
    int flag,stt;
    while(getline(cin,st))
    {
        flag=0;
        stt=0;
        for(int i=0; i<st.size();)
        {
            if(st[i]=='E'&&st[i+1]=='O'&&st[i+2]=='F')
            {
                stt=1;
                break;
            }
            if(st[i]=='p'&&st[i+1]=='i'&&st[i+2]=='n'&&st[i+3]=='k')
            {
                flag=1;
                printf("floyd");
                i+=4;
                continue;
            }
            if(st[i]=='d'&&st[i+1]=='d')
            {
                flag=1;
                printf("p");
                i+=2;
                continue;
            }
            if(st[i]=='e'&&st[i+1]=='i')
            {
                if(st[i-1]!='c')
                {
                    flag=1;
                    printf("ie");
                    i+=2;
                    continue;
                }
            }
            if(st[i]==' '||(st[i]>='a'&&st[i]<='z'))
            {
                flag=1;
                cout<<st[i];
            }
            i++;
        }
        if(stt)
            break;
            printf("\n");

    }
    return 0;
}

题目描述

In a letter dated December 25, 1640; the great mathematician Pierre de Fermat wrote to Marin Mersenne that he just proved that an odd prime p is expressible as p = a2 + b2 if and only if p is expressible as p = 4c + 1. As usual, Fermat didn’t include the proof, and as far as we know, never
wrote it down. It wasn’t until 100 years later that no one other than Euler proved this theorem.
To illustrate, each of the following primes can be expressed as the sum of two squares:
5 = 2 2 + 1 2
13 = 3 2 + 2 2
17 = 4 2 + 1 2
41 = 5 2 + 4 2
Whereas the primes 11, 19, 23, and 31 cannot be expressed as a sum of two squares. Write a program to count the number of primes that can be expressed as sum of squares within a given interval.
 
 

输入

Your program will be tested on one or more test cases. Each test case is specified on a separate input line that specifies two integers L, U where L ≤ U < 1, 000, 000
The last line of the input file includes a dummy test case with both L = U = −1.
 

输出

L U x y
where L and U are as specified in the input. x is the total number of primes within the interval [L, U ] (inclusive,) and y is the total number of primes (also within [L, U ]) that can be expressed as a sum of squares.
 

示例输入

10 20
11 19
100 1000
-1 -1

示例输出

10 20 4 2
11 19 4 2
100 1000 143 69

提示

 
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
bool visit[1010000];
int prime[1000100];
int num = 0;
void init_prim(int n)
{
    memset(visit, true, sizeof(visit));
    for (int i = 2; i <= n; ++i)
    {
        if (visit[i] == true)
        {
            num++;
            prime[num] = i;
        }
        for (int j = 1; ((j <= num) && (i * prime[j] <= n));  ++j)
        {
            visit[i * prime[j]] = false;
            if (i % prime[j] == 0) break;
        }
    }
}
int main()
{
    init_prim(1000000);
    visit[0]=0;
    visit[1]=0;
    int l,p;
    int ans1,ans2;
    int x,y;
    while(scanf("%d%d",&l,&p))
    {
        if(l==-1&&p==-1)
            break;
        ans1=ans2=0;
        for(int i=0; i<=num; i++)
            if(prime[i]&&prime[i]>=l&&prime[i]<=p)
            {
                if((prime[i]-1)%4==0)
                    ans2++;
                ans1++;
            }
        if(l<=2&&p>=2)
            ans2++;
        printf("%d %d %d %d\n",l,p,ans1,ans2);
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值