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);
}
}

最新文章

  1. java certificate 工具 portecle.sourceforge.net
  2. 引入math模块中的log()方法,导致&quot;TypeError: return arrays must be of ArrayType&quot;,什么原因?
  3. document.createElement()方法
  4. 两个viewport的故事(第一部分)
  5. http协议详解&lt;一&gt;
  6. haartraining生成.xml过程
  7. 有哪些关于 Android 开发的博客值得订阅?
  8. Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)
  9. libsvm 之 easy.py(流程化脚本)注释
  10. 大作业关于(“有爱”youi)的简介
  11. Osmocom-BB中cell_log的多种使用姿势
  12. C puzzles详解【21-25题】
  13. 使用 getNextException() 来检索已经过批处理的特定元素的异常。 ERRORCODE=-4228, SQLSTATE=null
  14. exist和not exist用法
  15. SQL Server中TempDB管理(version store的逻辑结构)
  16. vps安装wordpress遇到的问题(lnmp)
  17. iOS中单例需要注意的
  18. Java 8 Documentation Download
  19. 【公告】关于8.8MIP组件审核平台故障的说明
  20. DRF 商城项目 - 日志处理

热门文章

  1. 利用gcc的__attribute__编译属性section子项构建初始化函数表【转】
  2. Windows 7 64 位操作系统安装 Ubuntu 17.10
  3. React 16 源码瞎几把解读 【二】 react组件的解析过程
  4. 作为一个新手的Oracle(DBA)学习笔记【转】
  5. elk系列6之tcp模块的使用【转】
  6. sql函数应用例子
  7. java经典面试题大全
  8. 观察者模式和java委托
  9. es 插件
  10. XSS与CSRF两种跨站攻击总结