Alove @ 2019-04-27 11:30:31
import java.util.Scanner;
public class Main {
public static boolean Check_Repetition(int[] array) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array.length && j != i; j++) {
if (array[i] == array[j] || array[i] == 0 || array[j] == 0) {
return false;
}
}
}
return true;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int A = scanner.nextInt();
int B = scanner.nextInt();
int C = scanner.nextInt();
int[] array = { -1, -2, -3, -4, -5, -6, -7, -8, -9 };
boolean bo = false;
for (int i = 123; i < 988; i++) {
array[0] = i % 10;
array[1] = i / 10 % 10;
array[2] = i / 100;
int j = (int) (((double) B / A) * i);
if (j < 1000) {
array[3] = j % 10;
array[4] = j / 10 % 10;
array[5] = j / 100;
int k = (int) (((double) C / A) * i);
if (k < 1000) {
array[6] = k % 10;
array[7] = k / 10 % 10;
array[8] = k / 100;
if (Check_Repetition(array)) {
bo = true;
System.out.println(i + " " + j + " " + k);
}
}
}
}
if (bo == false) {
System.out.println("No!!!");
}
}
}
数组用来判断1-9有没有重复
只循环第一个数字,第二、三个数字用比例直接计算 大大减少了循环的次数
我觉得我的方法特别神仙,竟然能全AC(滑稽)
by babingbaboom @ 2019-04-27 11:38:02
啊,我好强啊,我太聚了,赶快膜我啊!
by lemonnyh @ 2019-04-27 11:48:36
@babingbaboom 莫不是被jfca了?!!
by _Life_ @ 2019-04-27 12:03:22
@babingbaboom jfca
by Kuriyama_Mirai @ 2019-04-27 12:05:37
@babingbaboom JC?
by Kuriyama_Mirai @ 2019-04-27 12:06:00
srO @lemonnyh Orz 偶遇隔壁班小姐姐一枚
by lemonnyh @ 2019-04-27 12:11:02
反弹,并且不接受其他任何形式的反弹、攻击
by lemonnyh @ 2019-04-27 12:11:07
@HarryJamesPotter