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

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 is:"Treasure the college life and seize the time." Most people thought that the college life should be 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 be spend on individual study and practise, especially on the latter one. I think the every one of you should take the learning attitude just as you have in senior school.
"No pain, No Gain", HDU also has scholarship, who can win it? That's mainly rely on the GPA(grade-point average) of the student had got. Now, I gonna tell you the rule, and your task is to program to caculate the GPA.
If there are K(K > 0) courses, the i-th course has 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 < 60, The GPA is always not existed.
 
Input
The first number N indicate that there are N test cases(N <= 50). In each case, there is a number K (the total courses number), then K lines followed, each line would obey the format: Course-Name (Length <= 30) , Credits(<= 10), Score(<= 100).
Notice: There is no blank in the Course Name. All the Inputs are legal
 
Output
Output the GPA of each case as discribed above, if the GPA is 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 two test cases. 
 
Sample Input
2
3
Algorithm 3 97
DataStruct 3 90
softwareProject 4 85
2
Database 4 59
English 4 81
 
Sample Output
90.10
Sorry!
 
代码:

#include <bits/stdc++.h>
using namespace std; int main()
{
int T;
char name[50];
double num[1111],score[1111];
scanf("%d",&T);
for(int i=1; i<=T; i++)
{
if(i!=1)
printf("\n");
int x,flag=0;
scanf("%d",&x);
double sum=0,ans=0;
for(int j=1; j<=x; j++)
{
scanf("%s%lf%lf",name,&num[j],&score[j]);
if(score[j]<60)
flag=1;
sum+=num[j]*score[j];
ans+=num[j];
}
//cout<<sum<<" "<<ans<<" "<<flag<<endl;
if(flag==0)
printf("%.2lf\n",sum/ans);
else
printf("Sorry!\n");
}
return 0;
}

  

HDU 2061 Treasure the new start, freshmen!的更多相关文章

  1. HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)

    Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No ...

  2. hdu2061 Treasure the new start, freshmen!(暴力简单题)

    Treasure the new start, freshmen! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  3. HDU 3468 Treasure Hunting(BFS+网络流之最大流)

    题目地址:HDU 3468 这道题的关键在于能想到用网络流.然后还要想到用bfs来标记最短路中的点. 首先标记方法是,对每个集合点跑一次bfs,记录全部点到该点的最短距离.然后对于随意一对起始点来说, ...

  4. hdu 2061

    PS:  以为找个简单来恢复信心..结果碰到那么傻逼的题目... 题意:给出学分和成绩,算GPA...关键是注意换行....它要求的换行我觉得超级奇怪...除了第一个正常,其他的输入完之后先一个换行. ...

  5. HDU 3641 Treasure Hunting(阶乘素因子分解+二分)

    题目链接:pid=3641">传送门 题意: 求最小的 ( x! ) = 0 mod (a1^b1*a2^b2...an^bn) 分析: 首先吧a1~an进行素因子分解,然后统计下每一 ...

  6. hdu 3641 Treasure Hunting 强大的二分

    /** 大意:给定一组ai,bi . m = a1^b1 *a2^b2 * a3^ b3 * a4^b4*...*ai^bi 求最小的x!%m =0 思路: 将ai 质因子分解,若是x!%m=0 那么 ...

  7. 【网络流】 HDU 3468 Treasure Hunting

    题意: A-Z&&a-z 表示 集结点 从A点出发经过 最短步数 走到下一个集结点(A的下一个集结点为B ,Z的下一个集结点为a) 的路上遇到金子(*)则能够捡走(一个点仅仅能捡一次) ...

  8. HDU100题简要题解(2060~2069)

    这十题感觉是100题内相对较为麻烦的,有点搞我心态... HDU2060 Snooker 题目链接 Problem Description background: Philip likes to pl ...

  9. hdu2060-2062

    hdu 2060 斯诺克,读懂题意直接模拟 #include<stdio.h> int main(){ int N; ]; a[]=; ;i<=;i++){ a[i]=(-i)*i/ ...

随机推荐

  1. WPF之ComboBox的VisualTreeHelper

    原文:WPF之ComboBox的VisualTreeHelper 用WPF的ComboBox控件的时候,需要用到TextChanged属性,但是这个属性属于TextBox控件,不用担心,ComboBo ...

  2. c++ 条件判断

    if语句 认识算术比较 运算符表达式用法 关系运算符表达式 一. 基本的if语句 if (条件成立) { 则执行此语句 }; // ) printf("条件成立"); 二.认识算术 ...

  3. RabbitMQ 安装 rabbitmq_delayed_message_exchange插件

    rabbitmq_delayed_message_exchange插件主要是实现延迟队列 一.下载插件 下载地址:http://www.rabbitmq.com/community-plugins.h ...

  4. Python函数之总结

    ''' 1.什么是函数 函数就是具备某一特定功能的工具 2.为什么用函数 减少重复代码 增强程序的扩展性 增强可读性 3.如何用函数 1.函数的使用原则:先定义后调用(*****) 定义阶段:只检测语 ...

  5. .NET:关于数据模型、领域模型和视图模型的一些思考

    背景 数据模型.领域模型和视图模型是“模型”的三种角色,一些架构用一种类型表示这三种角色,如:传统三层架构.也有一些架构用两种类型表示这三种角色,如:结合ORM的领域驱动架构.非常少见的场景是用三种类 ...

  6. GitLab篇之备份还原

    1. GitLab备份配置 输入以下命令,打开gitlab配置文件 [root@code-server ~]# vim /etc/gitlab/gitlab.rb 修改以下配置,gitlab有自动清理 ...

  7. java基础---类加载和对象创建过程

    类中可以存在的成员: class A{ 静态成员变量: 非静态成员变量: 静态函数: 非静态函数: 构造函数 A(..){...} 静态代码块 static{...} 构造代码块 {...} } 类加 ...

  8. java中JVM的原理

    转载:https://blog.csdn.net/witsmakemen/article/details/28600127 一.java虚拟机的生命周期: Java虚拟机的生命周期 一个运行中的Jav ...

  9. cmd下执行mysql

    1.  mysql -uroot -p1234; 2.  show databases; 3.  use testnode; 4. 创建数据库表 CREATE DATABASE `node` DEFA ...

  10. FileZilla-FTP连接失败

    状态: 已登录状态: 读取“/”的目录列表...命令: CWD /响应: 250 CWD successful. "/" is current directory.命令: TYPE ...