• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

2013 Asia Nanjing Regional Contest A

GPA

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 276    Accepted Submission(s): 159

Problem Description
In college, a student may take several courses. for each course i, he earns a certain credit (ci), and a mark ranging from A to F, which is comparable to a score (si), 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’s credit in GPA computation is 0, his/her GPA will be “0.00”.
 
Input
There are several test cases, please process till EOF. Each test case starts with a line containing one integer N (1 <= N <= 1000), the number of courses. Then follows N lines, each consisting the credit and the mark of one course. Credit is a positive integer and less than 10.
 
Output
For each test case, print the GPA (rounded to two decimal places) as the answer.
 
Sample Input
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
Hint
For the first test case: GPA =(3.0 * 2 + 1.0 * 3 + 0.0 * 1 + 4.0 * 3)/(2 + 3 + 1 + 3) = 2.33 For the second test case: because credit in GPA computation is 0(P/N in additional treatment), so his/her GPA is “0.00”.
 
Source
2013ACM/ICPC亚洲区南京站现场赛——题目重现
 
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  4812 4811 4810 4809 4808 
 1 #include <cstdio>
 2 #include <vector>
 3 #include <cmath>
 4 #include <queue>
 5 #include <cstring>
 6 #include <iostream>
 7 #include <algorithm>
 8 using namespace std;
 9 #define INF 0x7fffffff
10 #define mod 1000000007
11 #define ll long long
12 #define maxn 1005
13 #define pi acos(-1.0)
14 int n, m, k, d, x, y,ans;
15 int a[maxn];
16 double s, t;
17 int vis[maxn][maxn];
18 int dp[maxn][maxn];
19 int dx [] = { 1, 0, -1, 0 };
20 int dy [] = { 0, 1, 0, -1 };
21 int main(){
22     while (~scanf("%d", &n)){
23         s = 0; t = 0;
24         for (int i = 0; i < n; i++){
25             double v;
26             char op[3];
27             scanf("%lf%s", &v, op);
28             if (strcmp(op, "A") == 0)s += 4.0*v,t+=v;
29             if (strcmp(op, "A-") == 0)s += 3.7*v, t += v;
30             if (strcmp(op, "B+") == 0)s += 3.3*v, t += v;
31             if (strcmp(op, "B") == 0)s += 3.0*v, t += v;
32             if (strcmp(op, "B-") == 0)s += 2.7*v, t += v;
33             if (strcmp(op, "C+") == 0)s += 2.3*v, t += v;
34             if (strcmp(op, "C") == 0)s += 2.0*v, t += v;
35             if (strcmp(op, "C-") == 0)s += 1.7*v, t += v;
36             if (strcmp(op, "D") == 0)s += 1.3*v, t += v;
37             if (strcmp(op, "D-") == 0)s += 1.0*v, t += v;
38             if (strcmp(op, "F") == 0)t += v;
39         }
40         printf(t==0?"0.00\n":"%.2lf\n", s / t);
41     }
42     return 0;
43 }
View Code
posted @ 2013-12-20 00:24  HaibaraAi  阅读(144)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3