目录
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
ICPC是国际大学生程序设计竞赛(International Collegiate Programming Contest)的简称,是全球最具影响力的大学生程序设计竞赛。
小Kimi的目标是长大之后能够参加ICPC全球总决赛(World Final),为此他在努力学习编程。
为了表达对ICPC的热爱,他决定编写一个程序,输入一个正整数N,输出N个连续的ICPC,同时他希望所有位于奇数位置的ICPC全部用大写字母,而偶数位置的ICPC全部用小写字母,即“icpc”。你试试能不能写出来?
输入
单组输入。
输入一个正整数N,N<=100。
输出
输出一行,包含N个连续的“ICPC”,其中奇数位置的ICPC全部用大写字母,而偶数位置的ICPC全部用小写字母。
样例输入 Copy
3
样例输出 Copy
ICPCicpcICPC
代码:
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int n=scan.nextInt();
- for(int i=1;i<=n;i++){
- if(i%2!=0){
- System.out.print("ICPC");
- }else {
- System.out.print("icpc");
- }
- }
-
- }
- }
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
小米同学在MC("我的世界")游戏中用积木块搭建了一个三维迷宫。
在三维迷宫中,X轴对应东西方向(东为正,西为负),Y轴对应南北方向(北为正,南为负),Z轴对应上下方向(上为正,下为负)。
现在小米在游戏中所控制的人物角色的初始坐标位置是(x, y, z),每接收到一个指令字符,角色将朝对应的方向移动一个单位长度。
在游戏中一共包含六个指令字符,“E”表示往东移动,“W”表示往西移动,“S”表示往南移动,“N”表示往北移动,“U”表示往上移动,“D”表示往下移动。
请问在执行一组移动指令后,人物角色的最终位置是多少?请按照X、Y和Z的顺序输出。
输入
单组输入。
第1行输入三个整数x、y和z,表示人物角色的初始坐标位置。其中,-1000<=x,y,z<=1000。两两之间用英文空格隔开。
第2行输入一个由六种字符“E”、“W”、“S”、“N”、“U”和“D”组成的字符串,字符串的长度不超过1000。
输出
输出移动之后人物角色的最终位置,按照X、Y和Z的顺序输出,两两之间用英文空格隔开。
样例输入 Copy
0 0 0 EWESNDUS
样例输出 Copy
1 -1 0
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int x= scan.nextInt();
- int y= scan.nextInt();
- int z= scan.nextInt();
- String str=scan.next();
- String[] arr=str.split("");
- for(int i=0;i
- if (arr[i].equals("E")){
- x+=1;
- } else if (arr[i].equals("W")) {
- x-=1;
- }
- else if (arr[i].equals("S")) {
- y-=1;
- }
- else if (arr[i].equals("N")) {
- y+=1;
- }
- else if (arr[i].equals("U")) {
- z+=1;
- }
- else if (arr[i].equals("D")) {
- z-=1;
- }
- }
- System.out.println(x+" "+y+" "+z);
- }
- }
2062: X星间谍
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
X星最近潜入了很多来自别的星球的间谍。
X星首领下令在X星都城门口实施实名登记制,每一个进出X星都城的人都需要登记。进城门时需要登记一下编号,出城门时需要再登记一下编号。
X星首领获得了一个疑似间谍的人的编号清单,假定最开始时所有疑似间谍的人都在城外。现在给出N个已经登记的编号(同一个人进城门和出城门的编号相同),因为有的人会反复进出X星都城,所以有的编号会被登记多次,但可以确保每一次登记都是真实可靠的。
请你根据这些登记的编号信息判断还有多少疑似间谍者仍然停留在X星都城内。
输入
单组输入。
第1行输入一个正整数N,表示N个被登记的编号。(N<=10^4)
第2行输入N个被登记的编号(字符串类型),两两之间用英文空格隔开,可能会有一些编号重复。
输出
输出疑似间谍者仍然停留在X星都城内的数量。
样例输入 Copy
6
0001 0002 0001 0002 0003 0002
样例输出 Copy
2
代码:
- import java.util.HashSet;
- import java.util.Scanner;
- import java.util.Set;
-
- public class Main {
- public static void main(String[] args) {
-
- Scanner scan=new Scanner(System.in);
-
- int count=0;
- int n= Integer.parseInt(scan.nextLine());
- String line= scan.nextLine();
- String[] arr=line.split(" ");
- Set
set=new HashSet<>(); - for (int i=0;i< arr.length;i++){
- set.add(arr[i]);
- }
- String[] arr1=set.toArray(new String[set.size()]);
- int[] m=new int[arr1.length];
- for(int i=0;i< arr1.length;i++){
- for (int j=0;j
- if(arr1[i].equals(arr[j])){
- m[i]++;
- }
- }
- for(int i=0;i
- if(m[i]%2!=0){
- count++;
- }
- }
- System.out.println(count);
- }}
2086: 奖牌榜
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
X星学校的运动会正在激烈进行中。
现在需要请你编写一个程序来显示所有班级的奖牌榜,显示规则如下:
(1) 优先按照金牌数量降序排列后显示。
(2) 如果金牌数相等则比较银牌数,银牌数多者显示在前。
(3) 如果金牌和银牌数都相等,则比较铜牌数,铜牌数多者显示在前。
(4) 如果金、银、铜数量均相等,则按照班级编号从小到大排列后显示。
(5) 需要按照班级编号、金牌数、银牌数、铜牌数、奖牌总数的顺序显示每个班级的奖牌情况。
已知X星学校的班级编号为一个四位正整数,且班级编号具有唯一性。
输入
单组输入。
第1行输入一个正整数N,表示班级的总数量,N<=9000。
接下来N行,每1行包含四个正整数,分别表示班级编号、金牌数、银牌数和铜牌数。金牌数、银牌数和铜牌数均小于100。两两之间用英文空格隔开。
输出
显示按照规则排序之后的奖牌榜,每一行都包含班级编号、金牌数、银牌数、铜牌数和奖牌总数,两两之间用英文空格隔开。
样例输入 Copy
4
1000 4 10 5
1001 5 11 6
1002 4 11 4
1003 4 10 5
样例输出 Copy
1001 5 11 6 22
1002 4 11 4 19
1000 4 10 5 19
1003 4 10 5 19
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- int[][] arr = new int[n][4];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < 4; j++) {
- arr[i][j] = scan.nextInt();
- }
- }
- Student[] stu = new Student[n];
- for (int i = 0; i < n; i++) {
- stu[i] = new Student(arr[i][0], arr[i][1], arr[i][2], arr[i][3]);
- }
- Student temp;
- //冒泡排序
- for (int i = 0; i < n - 1; i++) {
- for (int j = 1; j < n - i; j++) {
- if (stu[j - 1].getClassno() > stu[j].getClassno()) {
- temp = stu[j - 1];
- stu[j - 1] = stu[j];
- stu[j] = temp;
- }
- }
- }
- for (int i = 0; i < n - 1; i++) {
- for (int j = 1; j < n - i; j++) {
- if (stu[j - 1].getCopperno() < stu[j].getCopperno()) {
- temp = stu[j - 1];
- stu[j - 1] = stu[j];
- stu[j] = temp;
- }
- }
- }
- for (int i = 0; i < n - 1; i++) {
- for (int j = 1; j < n - i; j++) {
- if (stu[j - 1].getSilverno() < stu[j].getSilverno()) {
- temp = stu[j - 1];
- stu[j - 1] = stu[j];
- stu[j] = temp;
- }
- }
- }
- for (int i = 0; i < n - 1; i++) {
- for (int j = 1; j < n - i; j++) {
- if (stu[j - 1].getGoldno() < stu[j].getGoldno()) {
- temp = stu[j - 1];
- stu[j - 1] = stu[j];
- stu[j] = temp;
- }
- }
- }
- for (int i = 0; i < n; i++) {
- int sum=stu[i].getGoldno()+stu[i].getSilverno()+stu[i].getCopperno();
- System.out.println(stu[i].getClassno() + " " + stu[i].getGoldno()+ " " + stu[i].getSilverno()+ " " + stu[i].getCopperno()+" "+sum);
- }
- }
- }
- class Student{
- private int classno;
- private int goldno;
- private int silverno;
- private int copperno;
- public Student(int classno,int goldno,int silverno,int copperno){
- this.classno = classno;
- this.goldno = goldno;
- this.silverno = silverno;
- this.copperno = copperno;
- }
-
- public int getClassno() {
- return classno;
- }
-
- public int getGoldno() {
- return goldno;
- }
-
- public int getSilverno() {
- return silverno;
- }
-
- public int getCopperno() {
- return copperno;
- }
- }
2064: 两个集合
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
现在有两个分别包含M和N个整数的集合S1和S2。S1中的元素互不相同,S2中的元素也互不相同。
给定一个整数K,然后从S1和S2中各选取一个整数,使得其和等于K。请问一共存在多少种不同的选取方案?
从S1中选取A、从S2中选取B与从S1中选取B、从S2中选取A是两种不同的选取方案。如果一种选取方案都不存在,则输出0。
输入
单组输入。
第1行输入三个整数M、N和K,其中,M和N均不超过10000。
第2行输入M个不同的整数,对应集合S1中的M个元素。
第3行输入N个不同的整数,对应集合S2中的N个元素。
输出
输出不同选取方案的数量;如果一种选取方案都不存在,则输出0。
样例输入 Copy
3 4 0
-1 1 2
-2 1 -1 0
样例输出 Copy
3
代码:
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int m= scan.nextInt();
- int n= scan.nextInt();
- int k= scan.nextInt();
- int[] S1=new int[m];
- int[] S2=new int[n];
- int count=0;
- for(int i=0;i
- S1[i]=scan.nextInt();
- }
- for(int i=0;i
- S2[i]=scan.nextInt();
- }
- for(int i=0;i
- for(int j=0;j
- if((S1[i]+S2[j])==k){
- count++;
- }
- }
- }
- System.out.println(count);
-
- }
- }
2065: 数字盒子
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
小米同学设计了一个数字盒子,只允许在该盒子的顶部对数字进行操作,操作类型包括以下三类:
(1) Add操作:如果盒子顶部有数字,则将数字加1;如果没有数字,则该操作无效。
(2) Push操作:将一个新的数字增加到盒子顶部,新增数字的初始值均为1(盒子可以装下所有的数字)。
(3) Pop操作:删除数字盒子顶部的数字;如果没有数字,则该操作无效。
请问通过N次操作之后,盒子顶部的数字是多少?如果最后盒子的顶部已经没有数字,则输出“No number.”。
输入
单组输入。
第1行输入一个正整数N(N<=1000)表示操作的总数量。
接下来N行每行包含一个操作指令,操作指令包括三类,分别是:Add、Push和Pop。
输出
输出通过N个操作之后盒子顶部的数字;如果最后盒子的顶部已经没有数字,则输出“No number.”。
样例输入 Copy
6
Push
Add
Pop
Push
Add
Add
样例输出 Copy
3
代码:
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int n=scan.nextInt();
- String[] arr=new String[n];
- for(int i=0;i
- arr[i]= scan.next();
- }
- int j=0;
- int[] a=new int[1002];
- for(int i=0;i
- if(arr[i].equals("Push")){
- j++;
- a[j]=1;
- }else if(arr[i].equals("Add")&&a[j]!=0){
- a[j]++;
- }else if(arr[i].equals("Pop")&&a[j]!=0){
- a[j]=0;
- j--;
- }
- }
- if(a[j]!=0){
- System.out.println(a[j]);
- }else {
- System.out.println("No number.");
- }
- }
- }
2066: 幸运数
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
小米爸爸的生日是6月17日,因此他特别喜欢“6”和“17”这两个数字,而且他觉得所有包含“6”和“17”的数字都是他的幸运数。当然“17”中的“1”和“7”必须连在一起才行。
现在输入两个正整数M和N,1<=M
输入
单组输入。
输入两个正整数M和N,满足1<=M 两个正整数之间用英文空格隔开。
输出
输出在M和N之间满足要求的幸运数的个数。
样例输入 Copy
1 20
样例输出 Copy
3
代码:
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int m= scan.nextInt();
- int n= scan.nextInt();
- int count=0;
- for(;m<=n;m++){
- String x= String.valueOf(m);
- if(x.contains("6")||x.contains("17")){
- count++;
- }
- }
- System.out.println(count);
- }
- }
2067: 十六进制
[命题人 : admin]
时间限制 : 1.000 sec 内存限制 : 128 MB
题目描述
小米同学最近在学习进制转换。众所周知,在表示十六进制数时,除了0-9这九个阿拉伯数字外,还引入了“A”、“B”、“C”、“D”、“E”和“F”这六个英文字母(不区分大小写)。
现在给你一个十进制正整数,请问在将其转换为十六进制之后,对应的十六进制表示中有多少位是字母?
输入
单组输入。
输入一个十进制正整数N(N<=10^6)。
输出
输出将N转换成十六进制数字后所包含的字母位的数量,如果没有字母位则输出0。
样例输入 Copy
20
样例输出 Copy
0
- import java.util.Scanner;
-
- public class Main{
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- int n=scan.nextInt();
- int count=0;
- while(n!=0){
- if(n%16>=10){
- count++;
- }
- n=n/16;
- }
- System.out.println(count);
- }
- }
-
相关阅读:
Vue基础使用
操作系统中文件系统的实现和分配方式探析(上)
NR/5G - PUSCH repetition次数
umi4项目:支持适配IE浏览器
Android 13 现已正式发布,看看有哪些更新!
linux进程间通讯--信号量
中断下半部之 tasklet
MATLAB图像处理入门
vue导入导出csv文件(插件papaparse + jschardet)
【云原生 | 44】Docker搭建Registry私有仓库之管理访问权限
-
原文地址:https://blog.csdn.net/m0_53653948/article/details/128090835