Nine degrees OJ 1002 Grading

Source: Internet
Author: User

Topic 1002:grading

time limit:1 seconds

Memory limit:32 MB

Special question: No

submitted:15686

Resolution:4053

Title Description:

Grading Hundreds of thousands of graduate Entrance exams is a hard work. It is even harder to design a process to make the results as fair as possible. One-to-assign each exam problem to 3 independent experts. If they do and agree to each other, a judge are invited to make the final decision. Now is asked to the write a program to help this process.
For each problem, there is a full-mark P and a tolerance T (<p) given. The grading rules are:
? A problem would first be assigned to 2 experts, to obtain G1 and G2. If the difference is within the tolerance, which is, if | g1-g2| ≤t, this problem ' s grade would be the average of G1 and G2.
? If the difference exceeds T, the 3rd expert would give G3.
? If G3 is within the tolerance with either G1 or G2, but not both, then this problem ' s grade would be the average of G3 and The closest grade.
? If G3 is within the tolerance with both G1 and G2, then this problem ' s grade'll be the maximum of the three grades.
? If G3 is within the tolerance with neither G1 nor G2, a judge would give the final grade GJ.

input :

    each input file could contain more than  One test case.
    occupies a line containing six positive integers:p, T, G1, G2, G3, and GJ, as described In the problem. It is guaranteed and the grades is valid, which is, in the interval [0, P].

Output:

For each test case you should output the final grade of the problem in a line. The answer must is accurate to 1 decimal place.

Sample input:
20 2 15 13 10 18
Sample output:
14.0
#include <stdio.h> #include <stdlib.h> #include <math.h>int p,t,g1,g2,g3,gj;int my_max (int x,int y) { return x>y?x:y;}    int main (int argc, char *argv[]) {while (scanf ("%d%d%d%d%d", &AMP;P,&AMP;T,&AMP;G1,&AMP;G2,&AMP;G3,&AMP;GJ)!=eof)        {if (ABS (G1-G2) <=t) printf ("%.1lf\n", (double) (G1+G2)/2.0);        else if (ABS (G1-G3) <=t&&abs (G2-G3) <=t) printf ("%.1lf\n", My_max (My_max (G1,G2), G3));        else if (ABS (G1-G3) >t&&abs (G2-G3) >t) printf ("%.1lf\n", (double) GJ);        else if (ABS (G1-G3) <=t&&abs (G2-G3) >t) printf ("%.1lf\n", ((double) (G3+G1))/2.0);    else if (ABS (G2-G3) <=t&&abs (G1-G3) >t) printf ("%.1lf\n", ((double) (G3+G2))/2.0); } return 0;} /************************************************************** problem:1002 User:kirchhoff language:c Resu lt:accepted time:0 Ms memory:912 kb****************************************************************/ 




Nine degrees OJ 1002 Grading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.