题目1
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int max = Integer.MIN_VALUE;int min = Integer.MAX_VALUE;double sum = 0;for(int i=0;i<n;i++) {int x = sc.nextInt();max = Math.max(max, x);min = Math.min(min, x);sum+=x;}System.out.println(max);System.out.println(min);System.out.printf("%.2f",sum/n);sc.close();}
}
题目2
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);
// if((2021%400 == 0)||(2021%100!=0 && 2021%4 == 0))
// System.out.println("yes");int[] date = {0,31,28,31,30,31,30,31,31,30,31,30,31};int y = sc.nextInt();int r = sc.nextInt();// if(y == 2) {// if(r > 28) {// System.out.println("no");// return ;// }else {// System.out.println("yes");// return ;// }// }for(int i=1;i<=12;i++) {if(y == i) {for(int j=1;j<=date[i];j++) {if(r == j) {System.out.println("yes");return ;}}}}System.out.println("no");sc.close();}
}
题目3
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int a = sc.nextInt();int b = sc.nextInt();int t = sc.nextInt();//分钟 int c1 = t/60;int c2 = t%60;a = a + c1;b = b + c2;if(b>=60) {a = a + b/60;b%=60;}System.out.println(a);System.out.println(b);sc.close();}
}
题目4
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();int[][] res = new int[n][m];int[][] sum = new int[n][m];for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {res[i][j] = sc.nextInt();if(res[i][j] == 1) {sum[i][j] = 9;}}}for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {if(res[i][j]!=1) {for(int x=i-1;x<=(i+1);x++) {for(int y=j-1;y<=(j+1);y++) {if((x>=0 && x<=(n-1))&&(y>=0 && y<=(m-1))&& res[x][y] == 1) {sum[i][j]++;}}}}}}for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {System.out.print(sum[i][j]+" ");}System.out.println();}sc.close();}
}
题目5
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);char[] c = sc.next().toCharArray();for(int i=0;i<c.length;i++) {if(c[i]>='a'&&c[i]<='z') {c[i]^=32;}}System.out.println(c);sc.close();}
}
题目6
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String s = sc.nextLine();String[] ss = s.split(" ");int sum = 0;for(int i=0;i<ss.length;i++) {sum+=ss[i].length();}System.out.println(sum);sc.close();}
}
题目7
public class Main {public static int res(int x) {int xx = x;while(xx!=0) {int t = xx%10;if(t == 2 || t == 0 || t == 1 || t == 9) {return x;}xx/=10;}return 0;}public static void main(String[] args) {int sum = 0;for(int i=1;i<=2019;i++) {sum+=res(i);}System.out.println(sum);}
}
题目8
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int[] date= {0,31,28,31,30,31,30,31,31,30,31,30,31};int n = sc.nextInt();for(int i=1;i<=12;i++) {if(n == i) {System.out.println(date[i]);return ;}}sc.close();}
}
题目9
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n];for(int i=0;i<n;i++)res[i] = sc.nextInt();int sum = 0;for(int i=1;i<n;i++) {sum = Math.max(sum, res[i]-res[i-1]);}System.out.println(sum);sc.close();}
}
题目10
import java.util.Scanner;public class Main {public static void main(String[] args) { Scanner sc = new Scanner(System.in);int n = sc.nextInt();int x = 1;int y = 0;//记录加的次数int sum = 0;//记录输出结果int i=1;//加的次数等于n时候结束for(;y<n;) {sum+=i;x-=1;y+=1;if(x == 0) {i++;x = i;}}System.out.println(sum);sc.close(); }
}
题目11
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;public class Main {public static void main(String[] args) {//去重与排序Scanner sc = new Scanner(System.in);int n = sc.nextInt();Set<Integer> set = new HashSet<>();List<Integer> list = new LinkedList<>();// List<Integer> list = new ArrayList<>();for(int i=0;i<n;i++) {int x = sc.nextInt();if(!set.contains(x)) {set.add(x);list.add(x);}}Collections.sort(list);System.out.println(list.size());for(int x:list) {System.out.print(x+" ");}sc.close();}
}
题目12
import java.util.Scanner;public class Main {public static void main(String[] args) {//0 2 0 0 0 0//2 * 2 2 0 0//0 2 2 * 2 0Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();int t = sc.nextInt();int[][] res = new int[n+1][m+1];int[][] ure = new int[n+1][m+1];for(int i=1;i<=t;i++) {int x = sc.nextInt();int y = sc.nextInt();res[x][y] = 1;ure[x][y] = 1; }int k = sc.nextInt();int sum = t;while(k!=0) {for(int i=1;i<=n;i++) {for(int j=1;j<=m;j++) {if(res[i][j] == 1 && ure[i][j] == 1) {if((i-1)>=1 && (i-1)<=n && res[i-1][j] != 1) {res[i-1][j] = 1;sum+=1;}if((i+1)>=1 && (i+1)<=n && res[i+1][j] != 1) {res[i+1][j] = 1;sum+=1;}if((j-1)>=1 && (j-1)<=m && res[i][j-1] != 1) {res[i][j-1] = 1;sum+=1;}if((j+1)>=1 && (j+1)<=m && res[i][j+1] != 1) {res[i][j+1] = 1;sum+=1;}}}}k--;}System.out.println(sum);sc.close(); }
}
题目13
public class Main {public static void main(String[] args) {int res = 0;int[] date = {0,31,28,31,30,31,30,31,31,30,31,30,31};for(int i=1900;i<=9999;i++) {if((i%400 == 0)||(i%100!=0 && i%4 == 0))date[2] = 29;elsedate[2] = 28; //一定要加这个else,否则闰年过后2月还是29天,没改回来for(int j=1;j<=12;j++) {for(int k=1;k<=date[j];k++) {int key1 = i;int sum1 = 0;while(key1!=0) {int t1 = key1%10;sum1 += t1;key1/=10;}//--int key2 = j;int sum2 = 0;while(key2!=0) {int t2 = key2%10;sum2 += t2;key2/=10;}//--int key3 = k;int sum3 = 0;while(key3!=0) {int t3 = key3%10;sum3 += t3;key3/=10;}if(sum1 == (sum2+sum3))res++;}}}System.out.println(res);}
}
题目14
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n+1];for(int i=1;i<=n;i++) {res[i] = sc.nextInt();}int ans = 0;for(int i=1;i<=n;i++) {for(int j=i+1;j<=n;j++) {ans = Math.max(ans, Math.abs(i-j)+Math.abs(res[i]-res[j]));}}System.out.println(ans);sc.close();}
}
题目15
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n+1];for(int i=1;i<=n;i++)res[i] = sc.nextInt();int ans = 0;int max = 0;for(int i=1;i<n;i++) {if(res[i]<res[i+1])ans++;else {max = Math.max(max, ans);ans = 0;}}System.out.println(max+1);sc.close();}
}