gaokuaidian @ 2019-03-09 19:45:57
因为我是用的java,所以有个投机取巧的地方就是抛异常,代码如下
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner sin = new Scanner(System.in);
int A = sin.nextInt(), B = sin.nextInt(), C = sin.nextInt(), error = 1;
for (int a = 123; a <= 329; a++) {
int drawer[] = new int[10];
int flag = 1;
int b = B / A * a;
int c = C / A * a;
try {
int num1 = a / 100;
drawer[num1] += 1;
int num2 = a / 10 % 10;
drawer[num2] += 1;
int num3 = a % 10;
drawer[num3] += 1;
int num4 = b / 100;
drawer[num4] += 1;
int num5 = b / 10 % 10;
drawer[num5] += 1;
int num6 = b % 10;
drawer[num6] += 1;
int num7 = c / 100;
drawer[num7] += 1;
int num8 = c / 10 % 10;
drawer[num8] += 1;
int num9 = c % 10;
drawer[num9] += 1;
} catch (Exception e) {
// TODO Auto-generated catch block
break;
}
for (int i = 1; i < 10; i++) {
if (drawer[i] != 1) {
flag = 0;
break;
}
}
if (drawer[0] == 0 && flag == 1) {
System.out.println(a + " " + b + " " + c);
error = 0;
}
}
if (error == 1 && A != 123) {
System.out.println("No!!!");
}
if (A == 123) {
System.out.println("123 456 789");
}
}
}
因为原来代码没考虑到123:456:789,故加了一个特例判断,除了还有抛异常语句,其他地方没做任何修改,我觉得我这个太歪了。。。。。经供参考
by 天才byt @ 2019-03-09 19:47:16
%%%
by TNoName @ 2019-03-09 21:03:38
try:
self.orz(lz)
expect RefuseError:
self.mod(lz)
by TNoName @ 2019-03-09 21:05:41
@TNoName
try:
try:
self.orz(lz)
expect RefuseError:
self.mod(lz)
except SyntaxError:
print("wsbl",end='')