HDU2061 Treasure The new start, freshmen! "Water problem"

Source: Internet
Author: User

Treasure The New start, freshmen!

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 11239 Accepted Submission (s): 3502
Problem Description
Background
A new semester comes, and the HDU also meets its 50th birthday. No matter what's your major, the only thing I want to tell you are: "Treasure the college life and seize the time." Most people thought the college life should is colorful, less presure. But in actual, the college life is also busy and rough. If you want to master the knowledge learned from the book, a great deal of leisure time should being spend on individual stud Y and practise, especially on the latter one. I think the every one of your should take the learning attitude just as you are in senior school.
"No pain, no Gain", HDU also have scholarship, who can win it? That's mainly rely on the GPA (Grade-point average) of the student had got. Now, I gonna that the rule, and your task is to program to caculate the GPA.
If there is k (k > 0) courses, the i-th course have the credit Ci, your score Si, then the result GPA is
GPA = (C1 * S1 + C2 * S2 +......+ci * Si ...)/(C1 + C2 + ...) + Ci ...) (1 <= i <= K, Ci! = 0)
If There is a 0 <= Si <, the GPA was always not existed.

Input
The first number n indicate that there is N test cases (n <= 50). In each case, there was a number K (the total courses number), then K-lines followed, each line would obey the Format:cour Se-name (Length <=), Credits (<=), score (<= 100).
Notice:there is no blank in the Course Name. All the Inputs is legal

Output
Output the GPA of each case as discribed above, if the GPA was not existed, ouput: "sorry!", else just output the GPA value Which is rounded to the 2 digits after the decimal point. There is a blank line between the test cases.

Sample Input
2
3
Algorithm 3 97
Datastruct 3 90
Softwareproject 4 85
2
Database 4 59
中文版 4 81

Sample Output
90.10

sorry!

Author
Zl

Source

Celebration Cup warm up


The sum of the schools according to the (score of each course credits *) ÷ total credits calculated average score. If you have

If the course is less than 60 minutes, the average score is not counted.


#include <iostream> #include <algorithm> #include <string>using namespace Std;int main () {    int t,n , Flag;    Double c,s,csum,cssum;    string S;    Cin >> T;    while (t--)    {        getchar ();        Cin >> N;        Flag = Csum = Cssum = 0;        while (n--)        {            cin >> s >> C >> s;            Csum + = C;            if (S < && s >=0)                flag = 1;            Cssum + = (c*s);        }        if (flag)            cout << "sorry!" << Endl;        else            printf ("%.2lf\n", cssum/csum);        if (T)            cout << Endl;    }    return 0;}


HDU2061 Treasure The new start, freshmen! "Water problem"

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.