GPA

Time Limit: 20 Sec  Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=4802

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”.

题意

算GPA!

题解:

签到题

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200001
#define mod 1000000007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** map<string,double> H;
int main()
{
//test;
int n;
H["A"]=4.0;
H["A-"]=3.7;
H["B+"]=3.3;
H["B"]=3.0;
H["B-"]=2.7;
H["C+"]=2.3;
H["C"]=2.0;
H["C-"]=1.7;
H["D"]=1.3;
H["D-"]=1.0;
H["F"]=;
H["N"]=;
H["P"]=;
while(scanf("%d",&n)!=EOF)
{
double num=;
double kiss=;
for(int i=;i<=n;i++)
{
int tmp=read();
string s;
cin>>s;
if(s=="N"||s=="P")
tmp=;
kiss+=H[s]*tmp;
num+=tmp;
}
if(num==)
cout<<"0.00"<<endl;
else
printf("%.2lf\n",kiss/num);
}
}

hdu 4802 GPA 水题的更多相关文章

  1. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  2. hdu 1251 (Trie水题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  3. HDU - 4802 - GPA (水题)

    题意: 计算GPA,输入一个数字和一个字符串,用 数字×字符串对应的数值 思路: 用map对应数值,要注意的是字符串为P或者N的时候,不计入结果 代码: #include<iostream> ...

  4. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  5. HDU 4493 Tutor 水题的收获。。

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...

  6. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  7. hdu 5495 LCS 水题

    LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...

  8. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  9. hdu 5734 Acperience 水题

    Acperience 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...

随机推荐

  1. 分布式队列Celery入门

    Celery 是一个简单.灵活且可靠的,处理大量消息的分布式系统,并且提供维护这样一个系统的必需工具.它是一个专注于实时处理的任务队列,同时也支持任务调度.Celery 是语言无关的,虽然它是用 Py ...

  2. Java杂知识汇总(自己积累的)

    [前提] 接下来,可能需要开始学习Java了,所以现在将前辈们传递给我的经验都记录下来,免得再次问他们. [积累] 1. 关于重启Tomcat服务器: 当在开发过程中, | 修改Java代码 -- 需 ...

  3. ubuntu下安装tftp服务器(转)

    安装了好几次tftp服务器,每次在网上找安装方法,找到的都不一样,有的能用,有的不能用,先把一个能用的版本做一个备忘. 参考链接:http://www.cnblogs.com/geneil/archi ...

  4. Spring mvc知识点总结——面试篇

    一.MVC思想MVC(Model-View-Controller)三元组的概念:1.Model(模型):数据模型,提供要展示的数据,因此包含数据和行为,可以认为是领域模型或JavaBean组件(包含数 ...

  5. python 爬图

    利用bs库进行爬取,在下载html时,使用代理user_agent来下载,并且下载次数是2次,当第一次下载失败后,并且http状态码是500-600之间,然后会重新下载一次 soup = Beauti ...

  6. CentOS_Linux服务器系统安装之分区

    在software selection中选择Server with GUI>(Compatibility Libraries.Development Tools和Security Tools) ...

  7. RGW 系统吞吐量(TPS)、用户并发量、性能测试概念和公式

      一.系统吞度量要素: 一个系统的吞度量(承压能力)与request对CPU的消耗.外部接口.IO等等紧密关联. 单个reqeust 对CPU消耗越高,外部系统接口.IO影响速度越慢,系统吞吐能力越 ...

  8. Asp.Net MVC4 之Url路由

    先来看下面两个个url,对比一下: http://xxx.yyy.com/Admin/UserManager.aspx http://xxx.yyy.com/Admin/DeleteUser/1001 ...

  9. System.Net.Mail的应用,后端发送邮件

    private void btn_send_Click(object sender, EventArgs e) { var emailAcount = ConfigurationManager.App ...

  10. LR 报错误: C interpreter run time error: Error -- Unresolved symbol : vuser_end解决方法

    Action.c(33): Error: C interpreter run time error: Action.c (33):  Error -- Unresolved symbol : vuse ...