2019校内发现杯大赛
发布日期:2021-05-14 16:28:37 浏览次数:24 分类:精选文章

本文共 5481 字,大约阅读时间需要 18 分钟。

??????????


2019???????

???????????????????????????????????????????????????????25?????????????????????????7????????????????????????????

Java????????

?2019???????

???????????????????????????????????????????????????????????????

System.out.println(Integer.toBinaryString(2019));

??????????????????????????

????????

System.out.println(Integer.valueOf("11111100011", 2)); // ???????
System.out.println(Integer.valueOf("876", 8)); // ???????
System.out.println(Integer.valueOf("FFFF", 16)); // ????????

????????????

System.out.println(Integer.toOctalString(876)); // ???????
System.out.println(Integer.toHexString(65535)); // ????????

????1200000??????????

????1200000??????????????????????????

int count = 0;
for (int i = 1; i <= Math.sqrt(1200000); i++) {
if ((1200000 / i) * i == 1200000) {
count++;
}
}
System.out.println(count * 2);

????????1??1200000??????????????1200000??????????????????????????????????????????????2?


????2019????????????????

???????????????????????????????????????????????2018???

????

  • ??????????????
  • ???2018???????????
  • ??????????????????????2018???

  • ????1-2019??9????????

    ????1?2019??9??????????????????????????

    public class Main {
    public static void main(String[] args) {
    int count = 0;
    for (int i = 0; i <= 2019; i++) {
    if (check(i)) {
    count++;
    }
    }
    System.out.println(count);
    }
    public static boolean check(int n) {
    while (n > 0) {
    if (n % 10 == 9) {
    return true;
    }
    n /= 10;
    }
    return false;
    }
    }

    ????

  • ???0?2019??????
  • ??????????????????9?
  • ????9?????1?

  • ??????????????????????

    ??????????????????????????????????????

    import java.util.*;
    public class Main {
    public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    int count = 0;
    for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (isVowelOrConsonant(c)) {
    count++;
    }
    }
    System.out.println(count);
    }
    private static boolean isVowelOrConsonant(char c) {
    c = Character.toLowerCase(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    return true;
    }
    if (c >= 'a' && c <= 'z') {
    return true;
    }
    return false;
    }
    }

    ????

  • ????????
  • ????????????
  • ???????????????
  • ????????????

  • ?????n?????????????m??????????????????

    ?????????????????????????????

    import java.util.*;
    public class Main {
    public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int count = 0;
    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
    numbers[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= i; j--) {
    if ((numbers[i] + numbers[j]) % m == 0) {
    count++;
    }
    }
    }
    System.out.println(count);
    }
    }

    ????

  • ????????
  • ??????????
  • ??????????m????
  • ????????????

  • ??????1~n????????????????????

    ????1?n??????????????????????????????????????

    import java.util.Scanner;
    public class Main {
    public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int count = 0;
    int n = scan.nextInt();
    for (int i = 1; i <= n; i++) {
    if (check(i)) {
    count++;
    }
    }
    System.out.println(count);
    }
    private static boolean check(int a) {
    int[] array = new int[10];
    while (a > 0) {
    array[a % 10]++;
    a /= 10;
    }
    for (int j = 0; j < 10; j++) {
    if (array[j] > 1) {
    return false;
    }
    }
    return true;
    }
    }

    ????

  • ??????n?
  • ???1?n??????
  • ?????????????????
  • ????????????

  • ?????????

    ??????????????????????????(1,1)??(m,n)????????d?????????

    ????

  • ?????(1,1)?(m,n)???????
  • ??x??y???????????
  • ????????x?y?????????

  • ????????????

    ?????????????????????????????????

    import java.util.*;
    public class Main {
    public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int[][] a = new int[n][m];
    for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
    a[i][j] = scan.nextInt();
    }
    }
    int[] sum = new int[m];
    for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
    sum[j] += a[i][j];
    }
    }
    int x = sum[0];
    int y = sum[m - 1];
    for (int k = m - 2; k >= 0; k--) {
    for (int r = 1; r <= k; r++) {
    if (x < y) {
    x += sum[r];
    } else {
    break;
    }
    if (r == k) {
    break;
    }
    }
    if (y > x && r + 1 > k) {
    System.out.println(y - x);
    break;
    }
    if (y > x && r == k) {
    break;
    }
    }
    if (x > y) {
    System.out.println(x - y);
    }
    }
    }

    ????

  • ???????????????
  • ???????????????
  • ??????????????

  • ???????????????????????


    ???????????????????????????????

    上一篇:弹性盒子
    下一篇:MYSQL索引为什么这么快?了解索引的神奇之处

    发表评论

    最新留言

    能坚持,总会有不一样的收获!
    [***.219.124.196]2025年05月01日 23时09分28秒