HDU 1804——What Is Your Grade?

本文介绍了一个根据学生解题数量及时间来评定成绩的评分系统。系统详细规定了不同解题数量对应的分数,并针对同一解题数量的学生根据完成时间先后给予不同的分数。文章还提供了一段C++代码实现此评分系统的逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

“Point, point, life of student!”
This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.
There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50.
Note, only 1 student will get the score 95 when 3 students have solved 4 problems.
I wish you all can pass the exam!
Come on!

Input

Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p.
A test case starting with a negative integer terminates the input and this test case should not to be processed.

Output

Output the scores of N students in N lines for each case, and there is a blank line after each case.

Sample Input

4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1

Sample Output

100
90
90
95

100

题目大意:意思大概是给学生打分数,做出的时间越短,题目越多,分数越高。

解决办法:题目不是很难,只要读懂题目,能对时间等数据进行妥善处理,就可以解决了

接下来是代码:
 1 #include<algorithm>
 2 #include<cstdlib>
 3 #include<iostream>
 4 #include<cstring>
 5 using namespace std;
 6 
 7 struct Node
 8 {
 9     int num;
10     int n;//题目
11     int fen;//分数
12     int time;//时间
13 }node[110];
14 
15 int cmp1(const void *a,const void *b)
16 {
17     struct Node *c=(Node *)a;
18     struct Node *d=(Node *)b;
19     if(c->n == d->n)return c->time - d->time;
20     return d->n - c->n;
21 }
22 
23 int cmp2(const void *a,const void *b)
24 {
25     struct Node *c=(Node *)a;
26     struct Node *d=(Node *)b;
27     return c->num - d->num;
28 }
29 
30 int main()
31 {
32     int n,i,j,k;
33     int sum[10];
34     int tol[10];
35     int h,m,s;
36     while(scanf("%d",&n))
37     {
38         if(n<0)break;
39         memset(sum,0,sizeof(sum));
40         memset(tol,0,sizeof(tol));
41         for(i=0;i<n;i++)
42         {
43             scanf("%d %d:%d:%d",&node[i].n,&h,&m,&s);
44             node[i].num=i;
45             node[i].time=h*3600+m*60+s;
46             sum[node[i].n]++;
47         }
48         for(i=4;i>0;i--)
49         {
50             tol[i]=tol[i+1];
51             tol[i]+=sum[i+1];
52         }
53         qsort(node,n,sizeof(node[0]),cmp1);//qsort对时间排序更为有效
54         for(i=0;i<n;i++)
55         {
56             node[i].fen=node[i].n*10+50;
57             if(node[i].n>=1&&node[i].n<5&&(((i+1)-tol[node[i].n])<=sum[node[i].n]/2))
58                 node[i].fen+=5;
59         }
60         qsort(node,n,sizeof(node[0]),cmp2);
61         for(i=0;i<n;i++)
62         {
63             printf("%d\n",node[i].fen);
64         }
65         printf("\n");
66     }
67     return 0;
68 
69 }

 



转载于:https://www.cnblogs.com/shadervio/p/5766598.html

资源下载链接为: https://pan.quark.cn/s/d9ef5828b597 在本文中,我们将探讨如何通过 Vue.js 实现一个带有动画效果的“回到顶部”功能。Vue.js 是一款用于构建用户界面的流行 JavaScript 框架,其组件化和响应式设计让实现这种交互功能变得十分便捷。 首先,我们来分析 HTML 代码。在这个示例中,存在一个 ID 为 back-to-top 的 div 元素,其中包含两个 span 标签,分别显示“回到”和“顶部”文字。该 div 元素绑定了 Vue.js 的 @click 事件处理器 backToTop,用于处理点击事件,同时还绑定了 v-show 指令来控制按钮的显示与隐藏。v-cloak 指令的作用是在 Vue 实例渲染完成之前隐藏该元素,避免出现闪烁现象。 CSS 部分(backTop.css)主要负责样式设计。它首先清除了一些默认的边距和填充,对 html 和 body 进行了全屏布局,并设置了相对定位。.back-to-top 类则定义了“回到顶部”按钮的样式,包括其位置、圆角、阴影、填充以及悬停时背景颜色的变化。此外,与 v-cloak 相关的 CSS 确保在 Vue 实例加载过程中隐藏该元素。每个 .page 类代表一个页面,每个页面的高度设置为 400px,用于模拟多页面的滚动效果。 接下来是 JavaScript 部分(backTop.js)。在这里,我们创建了一个 Vue 实例。实例的 el 属性指定 Vue 将挂载到的 DOM 元素(#back-to-top)。data 对象中包含三个属性:backTopShow 用于控制按钮的显示状态;backTopAllow 用于防止用户快速连续点击;backSeconds 定义了回到顶部所需的时间;showPx 则规定了滚动多少像素后显示“回到顶部”按钮。 在 V
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值