2031题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
while (sc_01.hasNext()) {
int num = sc_01.nextInt();
int jinzhi = sc_01.nextInt();
ArrayList arrayList_01 = new ArrayList();
if (num >= 0) {
while (num / jinzhi != 0) {
int tmp = num % jinzhi;
num = num / jinzhi;
arrayList_01.add(checknum(tmp));
}
//末尾的数加进去
arrayList_01.add(checknum(num % jinzhi));
for (int j = arrayList_01.size() - 1; j >= 0; j--) {
System.out.print(arrayList_01.get(j));
}
System.out.println();
}else{
while (Math.abs(num) / jinzhi != 0) {
int tmp = Math.abs(num) % jinzhi;
num = Math.abs(num) / jinzhi;
arrayList_01.add(checknum(tmp));
}
//末尾的数加进去
arrayList_01.add(checknum(Math.abs(num) % jinzhi));
arrayList_01.add("-");
for (int j = arrayList_01.size() - 1; j >= 0; j--) {
System.out.print(arrayList_01.get(j));
}
System.out.println();
}
}
}
private static String checknum(int tmp) {
if (tmp < 10) {
return String.valueOf(tmp);
} else {
String Greater_10 = new String();
switch (tmp) {
case 10:
Greater_10 = "A";
break;
case 11:
Greater_10 = "B";
break;
case 12:
Greater_10 = "C";
break;
case 13:
Greater_10 = "D";
break;
case 14:
Greater_10 = "E";
break;
case 15:
Greater_10 = "F";
break;
default:
break;
}
return Greater_10;
}
}
}
2033题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
int num_line = sc_01.nextInt();
for (int i = 0; i < num_line; i++) {
int []time = new int[6];
for(int j = 0;j
2070题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
while (sc_01.hasNext()) {
int num_01 = sc_01.nextInt();
ArrayList arrayList_01 = new ArrayList();
arrayList_01.add((long) 0);
arrayList_01.add((long) 1);
if (num_01 != -1) {
if(num_01 == 0 ){
System.out.println(arrayList_01.get(0));
}else if(num_01 ==1){
System.out.println(arrayList_01.get(1));
}else {
for(int i=2;i<=num_01;i++){
arrayList_01.add(arrayList_01.get(i-1)+arrayList_01.get(i-2));
}
System.out.println(arrayList_01.get(arrayList_01.size()-1));
}
}else{
break;
}
}
}
}
2071题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
int group_num = sc_01.nextInt();
for (int i = 0; i < group_num; i++) {
int stu_num = sc_01.nextInt();
double Max = -1;
for (int j = 0; j < stu_num; j++) {
double stu_height = sc_01.nextDouble();
if (Max < stu_height) {
Max = stu_height;
}
}
System.out.println(String.format("%.2f",Max));
}
}
}
2075题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
int line_num = sc_01.nextInt();
for(int i = 0;i
2089题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
int[] all_num = new int[1000001];
int counting = 0;
//使用累加法
for (int i = 1; i <= 1000000; i++) {
String deal_str = String.valueOf(i);
if (deal_str.contains("4") || deal_str.contains("62")) {
all_num[i] = all_num[i - 1] ;
} else {
all_num[i] = all_num[i-1] +1;//不吉利的个数。
}
}
while (sc_01.hasNext()) {
int begin_num = sc_01.nextInt();
int end_num = sc_01.nextInt();
if (begin_num == 0 && end_num == 0) {
break;
} else {
//这样时间复杂度过高,必须先行计算所有数组元素,输入之后数值这样执行时间会减少。
System.out.println(all_num[end_num]-all_num[begin_num-1]);
}
}
}
}
2090题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
double result = 0;
while (sc_01.hasNext()){
String veg_name = sc_01.next();
double vag_wei = sc_01.nextDouble();
double vag_pri = sc_01.nextDouble();
result+=(vag_wei *vag_pri);
}
System.out.println(String.format("%.1f",result));//人家自己就有四舍五入。
}
}
2092题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
while (sc_01.hasNext()) {
int num_01 = sc_01.nextInt();
int num_02 = sc_01.nextInt();
int tmp = 0;
if (num_01 == 0 && num_02 == 0) {
break;
} else {
tmp = -Math.max(Math.abs(num_01),Math.abs(num_02));
boolean result = check(num_01, num_02, tmp);
if (result) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
}
private static boolean check(int num_01, int num_02, int tmp) {
for (int i = tmp; i <= Math.abs(tmp); i++) {
if (i != 0) {
if (num_02 % i == 0 && (num_02 / i + i) == num_01) {
return true;
}
}
}
return false;
}
}
2096题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
int line_num = sc_01.nextInt();
for(int i = 0 ;i-100){
return Math.abs(num_01);
}else{
num_01 = Math.abs(num_01);
String tmp = String.valueOf(num_01);
return Integer.parseInt(tmp.substring(tmp.length()-2,tmp.length()));
}
}
}
2097题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
while (sc_01.hasNext()) {
int orig_value = sc_01.nextInt();
if (orig_value != 0) {
//十进制各位数之和
int sum_ten = get_result(orig_value,10);
int sum_twelve = get_result(orig_value,12);
int sum_sixteeen = get_result(orig_value,16);
if (sum_ten == sum_sixteeen && sum_ten == sum_twelve && sum_twelve == sum_sixteeen) {
System.out.println(orig_value+" is a Sky Number.");
} else {
System.out.println(orig_value+" is not a Sky Number.");
}
} else {
break;
}
}
}
//一定要保证能跑通多个测试用例,要巧。
private static int get_result(int orig_value, int i) {
int counting = 0;
while (orig_value!=0){
counting += (orig_value % i);
orig_value = orig_value / i;
}
return counting;
}
}
2098题:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
//输出1w以内的整数。
while (sc_01.hasNext()) {
int counting = 0;
int test_num = sc_01.nextInt();
//加入二元素
//每隔两个加一
if (test_num != 0) {
//因为素数是从3开始的且每次+2操作,因为偶数肯定不是素数。
for (int i = 3; i < test_num / 2; i=i+2) {
//无需存储进数组和判断,只需要判定每一次结果是否是素数即可,两者均是素数,则count+1;两步并一步相当于。
if(checkSushu(i) && checkSushu(test_num -i)){
counting++;
}
}
System.out.println(counting);
} else {
break;
}
}
}
//若为素数,时间老超。
private static boolean checkSushu(int num) {
for (int i = 3; i <= Math.sqrt(num); i = i + 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
}
2099题:
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc_01 = new Scanner(System.in);
while (sc_01.hasNext()) {
int num_1 = sc_01.nextInt();
int num_2 = sc_01.nextInt();
ArrayList arrayList_01 = new ArrayList();
//判断并放进动态数组里
if (num_1 != 0 && num_2 != 0) {
for (int i = 0; i < 100; i++) {
if ((num_1 * 100 + i) % num_2 == 0) {
arrayList_01.add(i);
}
}
} else {
break;
}
//输出该数组内容
for(int i = 0;i