博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UESTC 1426 Boring Ranking
阅读量:4468 次
发布时间:2019-06-08

本文共 4232 字,大约阅读时间需要 14 分钟。

Boring Ranking
Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu

Description

New term is coming, so the annual scholarship is going to be distributed. But Alibaba can’t wait to know how much he can get. Now he gets all the info including every course’s score and quality score of every student. He is too impatient to ask you for help.

As a UESTCer, you must know the evaluation method of scholarship. If you aren’t familiar with it, you can refer to the following description.
Your score consists of two parts: basis score and quality score.
Basis score is the weighted average score of all courses’ scores. Every course has a weight coefficient. Assume Si and Wi are the score and weight coefficient of the ith course, then the weighted average score is equal to:
                                         
Quality score is up to your performance in science and technology activities, competitions and student works.
At first, all students are ranked by basis score, and divided into 4 groups: top 10%, next 20%, then next 30% and others. And then every student is ranked only in his/her group according to the sum of basic score and quality score.
Alibaba wants to know the final ranklist of top 3 groups because the last 40% can’t get the scholarship. Can you tell him?

Input

The first line of input contains an integer T (T <= 20), which is the number of test cases that follow.

For each test case:
There are two integers N and M (10<=N<=100, 1<=M<=20) in the first line, which is the number of students and courses. 
Then N lines follow, each of them containing a string. The string in ith line is the name of the ith student. All strings only consist of lowercase letters and the length isn’t larger than 20.
Then a single line follows containing M integers. The ith integer is Wi indicating the weight coefficient of the ith course. All weight coefficients are in the range [1,6].
Then N lines follow, each of them containing M integers separated by single spaces. The jth element in the ith line is the jth course’s score of the ith student. All scores are in the range [0,100].
Then N lines follow, each of them containing a single integer indicating the quality score. All scores are in the range [0,20].
You can assume every student’s name, basis score and final score are unique, and N is a multiple of 10.

Output

For every test case, you should output "Case #k:" first in a single line, where k indicates the case number and starts at 1. Then output the final ranklist of top 3 groups who get the scholarship. Print a blank line between every two adjacent groups, and print a blank line after every test case.

Sample Input

1

10 1
standy
totalfrank
total
frank
frost
joyzhang
uestc
uestcmelody
acm
icpc
5
90
92
65
30
50
60
85
95
80
88
10
3
12
8
6
3
5
1
20
5

Sample Output

Case #1:

uestcmelody
standy
totalfrank
acm
icpc
uestc

题目大意:给定10的倍数个学生的成绩(基础成绩和品质成绩),然后排序出能获得奖学金的学生,其中先按基础成绩排名,分成四组,分别占10%,20%,30%,40%,然后对前三组,按总成绩(基础成绩+品质成绩)排名。

题目的意思不难理解,而且也是很好写的模拟题目,但是有很多小点需要注意,最需要注意的是doule转int精度损失问题

以下是转发大牛博客上的解释:

double f;

int num =(int) f*100;

结果是:输入f = 1.23,  输出 num = 122.

  输入f = 1.25  输出 num =125

这就是著名的double精度损失问题。

因为1.23在计算机里面只能表示为近似值:1.2299999999.........

而1.25却能被精确的表示:

解决的办法是:

int num = (int)(f*100+0.0001),这个0.0001根据你需要的精度来设置,是可以改变的

这时候,不管f=1.23还是f=1.25,结果都是我们想要的123和125.

关键是要理解:  10110101 只是近似等于 1.0110101 * 2^7.

 

其他的问题还有用sort排序,而不用qsort排序;用个gets(s),而不用getchar();

代码如下:

View Code
1 # include
2 # include
3 # include
4 # include
5 # include
6 using namespace std; 7 //# define eps 1e-9 高手经常把这个eps定义上,来防止精度损失 8 struct node{ 9 char name[22];10 double basis;11 double quality;12 }st[110];13 double w[25],sum;14 int n,m;15 16 //使用qsort排序就会出错,不知道为什么17 int cmp1(node a,node b){18 return a.basis > b.basis;19 }20 int cmp2(node a,node b){21 return a.quality > b.quality;22 }23 24 int main(){25 int T,cas,i,j;26 double t;27 char ss[22];28 scanf("%d",&T);29 for(cas=1;cas<=T;cas++)30 {31 scanf("%d%d",&n,&m);32 gets(ss); //getchar()也会出错33 for(i=0;i

 

 

转载于:https://www.cnblogs.com/acm-bingzi/archive/2013/05/09/3069970.html

你可能感兴趣的文章
openstack-云计算概述
查看>>
javascript的作用域以及闭包现象
查看>>
线程处理
查看>>
DB2日期和时间常用汇总
查看>>
JAVA运算符
查看>>
信号基础知识
查看>>
HTML转义字符大全
查看>>
安装Visual Studio 时窗口闪过就退出
查看>>
计算机底层是如何访问显卡的?
查看>>
Maven Assembly plugin and Spring Namespace handlers
查看>>
VS2012旗舰版接选择调试 出现了这样一个错误
查看>>
C++如何保留2位小数输出
查看>>
BZOJ 3343 教主的魔法 分块
查看>>
hadoop-2.6.0 Unhealthy Nodes 问题
查看>>
Linux 驱动之内核定时器
查看>>
作业5散列函数安全性的知识扩展+2016012102+曹滢
查看>>
POJ3259 Wormholes(最短路)
查看>>
关于set
查看>>
《探索性软件测试》
查看>>
C/C++通过WMI和系统API函数获取获取系统硬件配置信息
查看>>