HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
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!
题意:
输入:name c s
只要有一个成绩s是小于60的,输出就是“Sorry!”。
如果大于等于60,就计算GPA,公式
GPA = (C1 * S1 + C2 * S2 +……+Ci * Si……) / (C1 + C2 + ……+ Ci……) (1 <= i <= K, Ci != 0)
注意格式:输出之间有一个空行。答案保留2位小数!
(%.2f)输出是按照四舍五入的形式的。题目也是这么要求的!
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t =sc.nextInt();
while(t-->0){
int m = sc.nextInt();
String str = "" ;
int c =0;
int s = 0;
boolean isSorry = false;
double num1=0;
double num2=0;
double a=0;
double b=0;
for(int i=0;i<m;i++){
str = sc.next();
a=sc.nextDouble();
b=sc.nextDouble();
if(b<60){
isSorry = true;
}else{
num1 = num1+a*b;
num2 = num2 +a;
}
}
if(isSorry){
System.out.println("Sorry!");
}else{
System.out.printf("%.2f",num1/num2);
System.out.println();
}
if(t!=0){
System.out.println();
}
}
}
}
HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)的更多相关文章
- HDU 2061 Treasure the new start, freshmen!
http://acm.hdu.edu.cn/showproblem.php?pid=2061 Problem Description background:A new semester comes , ...
- HDOJ/HDU 1256 画8(绞下思维~水题)
Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...
- HDOJ(HDU) 1898 Sempr == The Best Problem Solver?(水题、、、)
Problem Description As is known to all, Sempr(Liangjing Wang) had solved more than 1400 problems on ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出
这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999 Problem Description: As we know,the sha ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- HDU 5583 Kingdom of Black and White 水题
Kingdom of Black and White Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showpr ...
- HDU 1159 Common Subsequence 公共子序列 DP 水题重温
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Common Subsequence Time Limit: 2000/1000 MS (Jav ...
随机推荐
- 深入浅出hive-hive简介
1. 什么是hive •Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供类SQL查询功能. •本质是将HQL转换为MapReduce程序 2. 为什么 ...
- 关于git的一些常用命令
1.git init 把目录变成Git可以管理的仓库 2.git add 把文件添加到仓库 3.git commit -m "" 把文件提交到仓库,-m后面是提交说明 4.git ...
- JS 获取元素的属性值,非内联样式
//获取样式表的属性值,IE8及以下不兼容 ,方法 window.getComputedStyle(dom对象,"伪类").style属性; //IE8及以下获取样式表的属性值 ...
- mac 查找当前目录下所有同一类型文件,并执行命令行
以TexturePacker举例 MAC下用TexturePacker命令行打包当前目录下所有的 *.tps文件 1.配置好tps文件需要配置好路径.参数等.(也可不配置,用命令行实现.具体参考:ht ...
- excel - 统计字符个数综合案例
本文通过一个综合的案例来介绍excel统计字符数的一些方法和思路,供大家参考和学习. 下图是一个excel数据源截图,我们逐一讲解不同条件的统计字符数. 第一,统计A2所有的字符数,不论是汉字和数字. ...
- 01-android快速入门
adb Android debug bridge 安卓调试桥 创建模拟器,屏幕尽量小些,启动速度运行速度快 Android项目的目录结构 Activity:应用被打开时显示的界面 src:项目代码 R ...
- tomcat中有关配置文件的说明
在以往的tomcat使用中本人一直都没有注意到tomcat的conf目录下配置文件的作用,都是"拿来主义"的思想,从未深究.但是最近遇到很多有关tomcat配置的问题,很是头大,所 ...
- WARN TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, worker1): java.lang.ClassNotFoundException: com.spark.firstApp.HelloSpark$$anonfun$2
进行如下设置,解决报错信息. val conf = new SparkConf().setAppName("helloSpark").setMaster("spark:/ ...
- 【USACO 3.1.2】总分
[描述] 学生在我们USACO的竞赛中的得分越多我们越高兴.我们试着设计我们的竞赛以便人们能尽可能的多得分,这需要你的帮助.我们可以从几个种类中选取竞赛的题目,这里的一个"种类"是 ...
- How to scroll the window using JQuery $.scrollTo() function
$('html, body').animate({scrollTop: $("#page").offset().top}, 2000); http://stackoverflow. ...