3 条题解

  • 2
    @ 2022-12-12 19:00:51
    #include <iostream>
    using namespace std;
    int main()
    {
    	cout << "192" << " " << "384" << " " << "576" << endl << "219" << " ";
    	cout << "438" << " " << "657" << endl << "273" << " " << "546" << " ";
    	cout << "819" << endl << "327" << " " << "654" << " " << "981" << endl;
    	return 0;
    }
    
    • 0
      @ 2023-10-28 22:02:16
      #include <iostream>
      #include <algorithm>
      using namespace std;
      int main(){
          int a[9]={1,2,3,4,5,6,7,8,9};
          do if((a[0]*100+a[1]*10+a[2])*2*3==(a[3]*100+a[4]*10+a[5])*1*3&&(a[0]*100+a[1]*10+a[2])*2*3==(a[6]*100+a[7]*10+a[8])*1*2)cout<<a[0]*100+a[1]*10+a[2]<<' '<<a[3]*100+a[4]*10+a[5]<<' '<<a[6]*100+a[7]*10+a[8]<<endl;
          while(next_permutation(a,a+9));
          return 0;
      }
      
      • 0
        @ 2023-1-29 11:32:34
        #include<bits/stdc++.h>
        using namespace std;
        /*
        循环第一个数的可能范围,由于第二个数是第一个数的2倍
        第三个数是第一个数的3倍,因此第一个数的范围最小是100,最大是333
        第一个数有了,第二个数和第三个数就有了,将三个数组合成一个9位数
        判断这个9位数各个位分别用到了数字1 ~ 9,那么这个3个数就是符合条件的数 
        */
        int main()
        {
        	int x, y, z;
        	//第一个3位数 
        	for(int i = 100; i <= 333; i++){
        		x = 2*i;//第二个
        		y = 3*i;//第三个
        		z = i*1000000 + x*1000 + y;//9位数
        		//如果z用到了1 ~ 9 的每个数
        		int a[10] = {0};
        		while(z != 0){
        			a[z%10]++;
        			z /= 10;
        		} 
        		//判断1 ~ 9是否出现了一次
        		bool f = true;//假设都出现了一次
        		for(int j = 1; j <= 9; j++){
        			if(a[j] != 1){
        				f = false;
        				break;
        			}
        		} 
        		if(f == true){
        			cout << i << " " << x << " " << y << endl;
        		}
        	}
        	return 0;
        }
        
        
        • 1

        信息

        ID
        464
        时间
        1000ms
        内存
        32MiB
        难度
        6
        标签
        递交数
        105
        已通过
        35
        上传者