# 第14届蓝桥杯 三月刷题第2天

``````public class Main {
public static void main(String[] args) {
for (int i = 2019; ; i += 2019) {
if (check(i)) {
System.out.println(i);
break;
}
}
}

static boolean check(int i) {
while (i > 0) {
if (i%2 == 0) return false;
i /= 10;
}
return true;
}
}``````

``````public class Main {

public static void main(String[] args) {
for (int i = 2; ; i++) {
int ans = 0;
for (int j = 1; j < i / j; j++) {
if (i % j == 0) ans++;
}
if (ans == 50) {
System.out.println(i);
return;
}
}
}
}
``````

``````import java.util.Scanner;

public class Main {
static int N = 200010;
static long[] a = new long[N];

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
a[i] = sc.nextInt();
}
long ans = 0;//保存结果
long sum = 0;//保存前i-1项的和
for (int i = 1; i <= n; i++) {
ans += a[i] * sum;
sum += a[i];
}
System.out.println(ans);
}
}
``````

``````import java.util.Arrays;
import java.util.Comparator;
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();
//要自定义排序的话 要用 Integer[]
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++) a[i] = i + 1;
//自定义排序
Arrays.sort(a, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
int a = check(o1);
int b = check(o2);
if (a != b) return a - b;
else return o1 - o2;
}
});
System.out.println(a[m - 1]);
}

//求数位和
private static int check(Integer x) {
int res = 0;
while (x != 0) {
res += x % 10;
x /= 10;
}
return res;
}
}``````

...全文
8 回复 打赏 收藏 举报

4.3w+

2023-03-05 23:07

刷题！