{朝花夕拾}xtu oj 1297 homework 重做

Homework

题目描述

鉴于很多同学Ctrl+A,Ctrl+C,Ctrl+V的问题,Eric想重新计算一下作业成绩,成绩计算的规则如下:

  1. 每道题按正确提交的先后顺序给分,第1-12名32,13-24名16分,25-48名8分,49-96名4分,97-192名2分,其余1分。
  2. 学生所有题目的分数累加和为其积分。
  3. 作业成绩=round(100+log(1+本人积分−最高积分最高积分)×10),其中round为四舍五入取整,log以自然对数为底。

Eric已经通过查询数据库得到每个人每道题的排名情况,请写一个程序帮Eric算一下所有人的作业成绩。

输入

输入包含若干行,每行是三个部分,题目号,学号,排名。
学生人数不超过500,题目数量不超过200。

输出

输出学号和成绩,按成绩逆序,学号,并按作业成绩逆序,学号正序排列显示。

样例输入

1054 2015551111 1
1054 2015551101 2
1054 2015551119 3
1054 2015551115 4
1054 2015551110 5
1054 2015551114 6
1054 2015551128 7
1054 2015551118 8
1054 2015551102 9
1054 2015551130 10
1054 2015551139 11
1054 2015551135 12
1054 2015551120 13
1054 2015551129 14
1054 2015551104 15
1054 2015551112 16
1054 2015551116 17
1054 2015551138 18
1054 2015551103 19
1054 2015551131 20
1054 2015551132 21
1054 2015551106 22
1054 2015551136 23
1054 2015551124 24
1054 2015551126 25
1054 2015551113 26
1054 2015551109 27
1054 2015551117 28
1054 2015551125 29
1054 2015551127 30
1054 2015551123 31
1054 2015551133 32
1054 2015551134 33
1054 2015551121 34
1054 2015551122 35
1054 2015551137 36

样例输出

2015551101 100
2015551102 100
2015551110 100
2015551111 100
2015551114 100
2015551115 100
2015551118 100
2015551119 100
2015551128 100
2015551130 100
2015551135 100
2015551139 100
2015551103 93
2015551104 93
2015551106 93
2015551112 93
2015551116 93
2015551120 93
2015551124 93
2015551129 93
2015551131 93
2015551132 93
2015551136 93
2015551138 93
2015551109 86
2015551113 86
2015551117 86
2015551121 86
2015551122 86
2015551123 86
2015551125 86
2015551126 86
2015551127 86
2015551133 86
2015551134 86
2015551137 86

 

Source Code

Problem: 1297		User: 202205567311
Memory: 1216K		Time: 46MS
Language: G++		Result: Accepted
Source Code

#include<stdio.h>
#include<math.h>
struct students {
    long long student_number;
    int score;
};
struct students student_message[590];
int TurnToStore(int number) {
    if (number > 192) return 1;
    if (number > 96) return 2;
    if (number > 48) return 4;
    if (number > 24) return 8;
    if (number > 12) return 16;
    return 32;
}
void whitetomessage(long long school_num, int score) {
    static int i;
    i = 0;
    while (student_message[i].student_number != 0) {
        if (student_message[i].student_number == school_num) {
            student_message[i].score += score;
            return;
        }
        i++;
    }
    student_message[i].student_number = school_num;
    student_message[i].score = score;
    return;
}
void sortall(int count,int withpaim){
    static int i,j;
    static struct students temp; 
    for( i=0;i<count-1;i++){
        for( j=1;j<count-i;j++){
            if((student_message[j].score>student_message[j-1].score&&!withpaim)||(withpaim&&(student_message[j].score==student_message[j-1].score)&&student_message[j].student_number<student_message[j-1].student_number)){
                temp=student_message[j];
                student_message[j]=student_message[j-1];
                student_message[j-1]=temp;
            }
        }
    }
    return;
}
void print(int cnt){
    static int i;
    for( i=0;i<cnt;i++){
        printf("%I64d %d\n",student_message[i].student_number,student_message[i].score);
    }
    return;
}
void turntoreallyscore(int cnt,int maxscore){
    static int i;
    for( i=0;i<cnt;i++){
        student_message[i].score=round(100+10*log(1+(double)(student_message[i].score-maxscore)/((double)maxscore)));
    }
    return;
}
int main(){
    int i,input_No_timu,input_No_student,Max_Number=0,count_message=0;
    long long school_number;
    while(scanf("%d%I64d%d",&input_No_timu,&school_number,&input_No_student)!=EOF){
        whitetomessage(school_number,TurnToStore(input_No_student));
    }
    for( i=0;student_message[i].student_number!=0;i++){
        Max_Number=(student_message[i].score>Max_Number)?student_message[i].score:Max_Number;
        count_message++;
    }
    turntoreallyscore(count_message,Max_Number);
    sortall(count_message,0);
    sortall(count_message,1);
    print(count_message);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值