当前位置:网站首页>Blue Bridge Cup - Castle formula

Blue Bridge Cup - Castle formula

2022-07-06 03:37:00 Deduce life

1. subject

2. Ideas Violence starts with 10000 Find the matching number Do it for the first time Five unequal conditions mean wrong Then improved The code is quite long

3. Code

public class J84 {
	public static void main(String[] args) {
		for(int i=10000;i<100000;i++) {
				int a=i/10000;// Ten thousand position 
				int b=i/1000%10;// Thousand bit 
				int c=i/100%10;// Hundred bit 
				int d=i/10%10;// ten 
				int e=i%10;// bits 
				int f=e*10000+d*1000+c*100+b*10+a;// Turn into  EDCBA
				for(int j=1;j<10;j++) {// The condition that five numbers are not equal to each other 
				if(a!=b&&a!=c&&a!=d&&a!=e&&b!=c&&b!=d&&b!=e&&c!=d&&c!=e&&d!=e) {
					if(i*j==f) {
						System.out.println(i);
					}
				}
			}
		}
	}
}

原网站

版权声明
本文为[Deduce life]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132314002267.html