Problem A.比赛须知
Description
小邯来参加邯郸学院大学生程序设计竞赛。由于这场比赛在线上举行,有很多需要遵守的规则。有一条规则是,为了避免对题目内容相关的提问被无关的提问淹没,所有和题目内容无关的询问主题都需要将关联题目设置为5-1。
比如,如果选手需要去洗手间,则需要发表新主题进行报备并且设置关联题目为5-1。在去洗手间回来之后,需要在这个主题上发表回复报备。监考人员会记录每次使用洗手间开始时间和结束时间,并且删掉这个主题。
假设小邯往返洗手间需要6分钟,给出小邯发出新主题进行报备的时间和对应主题所设置的关联题目,请计算在符合比赛规则的条件下,他会在什么时候用完洗手间回来。
Input
第一行包含一个字符串T(1 ≤ T ≤ 103),表示数据组数。
接下来T行, 每行包含两个字符串, 第一个字符串为HH:MM的形式, 表示发表报备主题的时间(从08:00到12:00),第二个字符串为5-X的形式,表示报备主题的关联题目。
Output
对于每组数据,输出一行形如HH:MM的字符串,表示小邯用完洗手间回来的时间。
Samplem Input
3
09:10 5-1
10:03 5-6
11:45 5-2
Samplem Ouput
09:16
12:06
12:06
Tip
第一组数据,在提交报备之后小邯就可以走了。
后两组数据,由于关联题目设置有误,此时直接去卫生间违反了比赛规则。因此需要等到12:00比赛结束之后再去,6分钟后也就是12:06回来。
题目来源:2020HBCPC Problem A. 须知
题解
package org.example;
import java.util.Arrays;
import java.util.Scanner;
/**
* @author mumuwei
* @date 2022/4/24
*/
public class PA {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());
for (int i = 0; i<n; i++) {
String next = scanner.nextLine();
String[] s = next.split(" ");
if ("5-1".equals(s[1])) {
String[] times = s[0].split(":");
int hour = Integer.parseInt(times[0]);
int minite = Integer.parseInt(times[1]);
if(minite +6 > 59){
hour++;
minite = minite +6 -60;
} else {
minite = minite +6;
}
String h = hour>=10?""+hour:("0"+hour);
String m = minite>=10?""+minite:("0"+ minite);
System.out.println(h+ ":" + m);
} else {
System.out.println("12:06");
}
}
}
}
Problem B.冬奥奖牌
Description
2022年北京冬奥会已经圆满闭幕,中国再一次让世界见证什么是了中国力量。在冬奥会期间,小邯发现在竞赛圈有个奇怪的现象,人们称呼奖牌的时候,喜欢使用化学符号Au、Ag和Cu来表示金、银、铜奖,而不是官方的gold、silver和bronze。
他非常无聊,于是就问你,奖牌官方称呼的单词对应的惯用符号是什么。如果他对你说gold,你就要回答他Au,以此类推。
Input
输入一行包含一个字符串,gold、silver或者bronze。
Output
输出对应的惯用符号。
Samplem Input 1
gold
Samplem Ouput 1
Au
Samplem Input 2
silver
Samplem Ouput 2
Ag
Samplem Input 3
bronze
Samplem Ouput 3
Cu
题目来源:2020HBCPC Problem J. 奖牌
题解
package org.example;
import java.util.Scanner;
/**
* @author mumuwei
* @date 2022/4/24
*/
public class PB {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s = scanner.nextLine();
switch (s){
case "gold":
System.out.println("Au");
break;
case "silver":
System.out.println("Ag");
break;
case "bronze":
System.out.println("Cu");
}
}
}
Problem C. Penalty time counts
Description
As we all know, in ACM series, a very important basis for ranking is penalty time.
Xiaohan, a new engineer, has developed an evaluation system. The calculation method of penalty time of the system is as follows:
- For each passed topic, the system will record the time a of the first pass and the number B of submissions that failed before, generate the corresponding string A + B (excluding quotation marks), and the corresponding contribution is A + B × 20.
- For other failed topics, the system will record the failed submission times C, generate a string - C (excluding quotation marks), and the corresponding contribution is 0.
Now Xiaohan has developed the function of generating string. He hopes you can help him realize the function of calculating the corresponding contribution through the string generated by the system.
Input
The first line is only an integer n, which indicates the number of generated strings.
From line 2 to line n + 1, each line is a string in the same format as the topic description, i.e. in the form of A+B or -C (excluding quotation marks).
Considering the actual situation, we ensure that all input data meet 1 ≤ n ≤ 20, 0 ≤ A, B, C ≤ 300.
Output
Output n lines, one integer per line. The integer in line I represents the penalty time of the contribution corresponding to the ith string.
Samplem Input
5
16+0
160+20
-3
255+6
-0
Samplem Ouput
16
560
0
375
0
题目来源:2021HBCPC Problem J. 罚时算术
题解
package org.example;
import java.util.Scanner;
/**
* @author mumuwei
* @date 2022/4/24
*/
public class PC {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for (int i = 0; i< n; i++) {
String line = scanner.next()