Java实现 洛谷 P1008 三连击

在这里插入图片描述

public class Main {
	public static void main(String[] args){
		
		for(int i = 123; i <= 329; i++){
			int[] tmp = new int[10];

			int b = 2*i;
			int c = 3*i;
			
			tmp[i%10] ++;
			tmp[i/10%10] ++;
			tmp[i/100] ++;
			
			tmp[b%10] ++;
			tmp[b/10%10] ++;
			tmp[b/100] ++;
			
			tmp[c%10] ++;
			tmp[c/10%10] ++;
			tmp[c/100] ++;
			
			boolean is = true;
			for(int j = 1; j < 10; j++){
				if(tmp[j]>1 || tmp[j]==0){
					is = false;
				}
				
			}
			
			if(is == true){
				System.out.println(i +" "+b+" "+c);
			}
		}
	}
}
原文地址:https://www.cnblogs.com/a1439775520/p/13076710.html