HDU 4802-GPA(水)
GPA
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1471 Accepted Submission(s): 902
Problem Description
In college, a student may take several courses. for each course i, he earns a certain credit (c
i), and a mark ranging from A to F, which is comparable to a score (s
i), according to the following conversion table
The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,
An additional treatment is taken for special cases. Some courses are based on “Pass/Not pass” policy, where stude nts earn a mark “P” for “Pass” and a mark “N” for “Not pass”. Such courses are not supposed to be considered in computation. These special courses
must be ignored for computing the correct GPA.
Specially, if a student喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcyBjcmVkaXQgaW4gR1BBIGNvbXB1dGF0aW9uIGlzIDAsIGhpcy9oZXIgR1BBIHdpbGwgYmUgobAwLjAwobEuCgogCjxicj4KCklucHV0CgpUaGVyZSBhcmUgc2V2ZXJhbCB0ZXN0IGNhc2VzLCBwbGVhc2UgcHJvY2VzcyB0aWxsIEVPRi48YnI+CkVhY2ggdGVzdCBjYXNlIHN0YXJ0cyB3aXRoIGEgbGluZSBjb250YWluaW5nIG9uZSBpbnRlZ2VyIE4gKDEgPD0gTiA8PSAxMDAwKSwgdGhlIG51bWJlciBvZiBjb3Vyc2VzLiBUaGVuIGZvbGxvd3MgTiBsaW5lcywgZWFjaCBjb25zaXN0aW5nIHRoZSBjcmVkaXQgYW5kIHRoZSBtYXJrIG9mIG9uZSBjb3Vyc2UuIENyZWRpdCBpcyBhIHBvc2l0aXZlIGludGVnZXIgYW5kIGxlc3MgdGhhbiAxMC4KCiAKPGJyPgoKT3V0cHV0CgpGb3IgZWFjaCB0ZXN0IGNhc2UsIHByaW50IHRoZSBHUEEgKHJvdW5kZWQgdG8gdHdvIGRlY2ltYWwgcGxhY2VzKSBhcyB0aGUgYW5zd2VyLgoKIAo8YnI+CgpTYW1wbGUgSW5wdXQKCjxwcmUgY2xhc3M9"brush:java;">5
2 B
3 D-
2 P
1 F
3 A
2
2 P
2 N
6
4 A
3 A
3 A
4 A
3 A
3 A
Sample Output
2.33
0.00
4.00#include
#include
#include
#include
using namespace std;
#define ll long long
int main()
{
int n,x;char s[5];
while(~scanf("%d",&n))
{
int sum_c=0;
double sum_cs=0;
while(n--)
{
scanf("%d %s",&x,s);
if(s[0]=='P'||s[0]=='N')
continue;
sum_c+=x;
double tem;
if(strlen(s)==1)
{
switch (s[0])
{
case 'A':tem=4;break;
case 'B':tem=3;break;
case 'C':tem=2;break;
case 'D':tem=1.3;break;
case 'F':tem=0;break;
}
}
else
{
if(!strcmp(s,"A-"))
tem=3.7;
else if(!strcmp(s,"B+"))
tem=3.3;
else if(!strcmp(s,"B-"))
tem=2.7;
else if(!strcmp(s,"C+"))
tem=2.3;
else if(!strcmp(s,"C-"))
tem=1.7;
else if(!strcmp(s,"D-"))
tem=1.0;
}
sum_cs+=(double)x*tem;
}
if(sum_c==0)
{
puts("0.00");
continue;
}
printf("%.2lf\n",sum_cs/(double)sum_c);
}
return 0;
}