9 条题解

  • 2
    @ 2025-9-17 20:21:47

    C语言解法

    #include <stdio.h>
    int main()
    {
    	int x=100;
    	for(;x<=333;x++){
    		int a=x,b=x*2,c=x*3;
    		int digits[10]={0};
    		int valid=1;
    		
    		int nums[]={a,b,c};
    		int i=0;
    		for(;i<3;i++){
    			int num=nums[i];
    			while(num>0){
    				int digit=num%10;
    				if(digit==0||digits[digit]++>0){
    					valid=0;
    					break;
    				}
    			num/=10;
    		    }
    		if(!valid)break;
    	    }
    	
    		if(valid){
    			int i=1;
    			for(;i<=9;i++){
    				if(digits[i]!=1){
    					valid=0;
    					break;
    				}
    			}
    		}
    		
    		if(valid){
    			printf("%d %d %d\n",a,b,c);
    		}
        }
    	return 0;
    }
    
    • 2
      @ 2025-2-10 20:07:56

      2.8洛谷讨论区倒闭来的 本人的第1篇题解

      思路

      这题只需要枚举 a,b,ca,b,c 的值就行了,然后把数字拆分后用桶的思想挨个检查即可。 至于 aa 的枚举范围从最小( 123123 )到 10003\lfloor\frac{1000}{3}\rfloor 就行。

      • 一定记得清0

      Code

      #include<bits/stdc++.h>
      using namespace std;
      int hydro[11]; // 用桶的思想来检查是否每个数只用一次
      int main(){
          for(int a=123;a<=1000/3;a++){ 
          	memset(hydro,0,sizeof(hydro));//一定记得清0!
              int b = 2*a;
              int c = 3*a;
              /*
              三位数的拆分:
              个位:x(/1)%10
              十位:x/10%10
              百位:x/100(%10)
              */
              hydro[a/100]++;
              hydro[a/10%10]++;
              hydro[a%10]++;
              hydro[b/100]++;
              hydro[b/10%10]++;
              hydro[b%10]++;
              hydro[c/100]++;
              hydro[c/10%10]++;
              hydro[c%10]++;
              bool flag = true;
              for(int i=1;i<=9;i++){
                  if(hydro[i] != 1){
                      flag = false;
                  }
              }
              if(flag == true){
                  cout << a << " " << b << " " << c << endl;
              }
          }
          return 0;
      }
      /* 
      附上自己算的:
      192 384 576
      219 438 657
      273 546 819
      327 654 981
      */
      
      • 1
        @ 2025-11-27 21:37:52
        #define int long long
        #define endl '\n'
        
        using namespace std;
        
        signed main () {
            cout << "192 384 576" << endl;
            cout << "219 438 657" << endl;
            cout << "273 546 819" << endl;
            cout << "327 654 981" << endl;
            return 0;
        }
        
        
        • 0
          @ 2025-10-6 11:55:40
          #include<iostream>
          #include<set>
          using namespace std;
          set<int>s = { 1,2,3,4,5,6,7,8,9 };
          int chai(int m)
          {
          	int a = 0, b = 0, c = 0;
          	a = m / 100;b = m / 10 % 10;c = m % 10;
          	if (a != b && a != c && b != c)
          		return 1;
          	else
          		return 0;
          }
          int naa(int m)
          {
          	int a = 0;
          	a = m / 100;
          	return a;
          }
          int nab(int m)
          {
          	int b = 0;
          	b = m / 10 % 10;
          	return b;
          }
          int nac(int m)
          {
          	int c = 0;
          	c = m % 10;
          	return c;
          }
          int quan(int x,int y,int z)
          {
          	int x1 = 0, x2 = 0, x3 = 0, y1 = 0, y2 = 0, y3 = 0, z1 = 0, z2 = 0, z3 = 0;
          	x1 = naa(x);x2 = nab(x);x3 = nac(x);
          	y1 = naa(y);y2 = nab(y);y3 = nac(y);
          	z1 = naa(z);z2 = nab(z);z3 = nac(z);
          	set<int>set1 = { x1,x2,x3,y1,y2,y3,z1,z2,z3 };
          	if (s == set1)
          		return 1;
          	else
          		return 0;
          }
          int main()
          {
          	for (int i = 123;i<=329;i++)
          	{if(chai(i) == 1 && chai(2 * i) == 1 && chai(3 * i) == 1 && quan(i, 2 * i, 3 * i) == 1)
          		cout << i << " " << 2 * i << " " << 3 * i << endl;
          	}
          	return 0;
          }
          
          • 0
            @ 2025-3-10 16:53:22

            思路:

            • 数字位于123到987之间;且不能重复;所以需要使用某种方式标记数字1-9是否被使用;
              • 用int充当位图来存储1-9是否完全覆盖;
            #include <iostream>
            using namespace std;
            int status = 0;
            /**
            * 将value每个位上的数字所对应的位置设置为1,表示存在;
            * eg. 3 ==> 0b1000;右移三位
            * param value: 数字
            */
            void set_bit(int value){
                while(value>0){
                    status |= 1 << (value%10);
                    value /=10;
                }
            }
            
            int main(){
                for(int i = 123; i < 333; ++i){
                    set_bit(i);
                    set_bit(i*2);
                    set_bit(i*3);
                    int ob = status & 0b1111111110;
                    if(ob==0b1111111110){
                        cout<<i<<" "<<i*2<<" "<<i*3<<endl;
                    }
                    status = 0;
                }
                return 0;
            }
            
            • 0
              @ 2024-11-4 17:39:27
              
              #include<bits/stdc++.h>
              using namespace std;
              int a,b,c; 
              int main(){
              	  for(a=123;a<=333; a++) {
              		b=2*a;
              		c=3*a;
              		if(((a/100)+(a/10%10)+(a%10)+(b/100)+(b/10%10)+(b%10)+(c/100)+(c/10%10)+(c%10)==1+2+3+4+5+6+7+8+9)&&(a/100)*(a /10%10)*(a%10)*(b/100)*(b/10%10)*(b%10)*(c/100)*(c/10%10)*(c % 10)==1*2*3*4*5*6*7*8*9){
              			cout<<a<<' '<<b<<' '<<c<<endl;
              		}
              	}
              	return 0;
              }
              
              • @ 2025-1-24 21:01:37

                牛逼,我还在用破dfs

              • @ 2025-10-6 12:00:39

                if括号里的条件只是必要的,并不充分啊!

            • -1
              @ 2025-6-12 13:46:02

              phthon

              print('''192 384 576
              219 438 657
              273 546 819
              327 654 981''');
              
              • -1
                @ 2025-2-25 23:09:50

                用for循环每次硬推出来

                AC code(求点赞)

                //抄题解不有趣
                #include<bits/stdc++.h>
                using namespace std;
                int main(){
                    for(int i=123;i<333;i++){
                        int a[10]={0},b[10]={0},c[10]={0};
                        a[1]=i%100%10;
                        a[2]=i%100/10;
                        a[3]=i/100;
                        b[1]=2*i%10%10;
                        b[2]=2*i%100/10;
                        b[3]=2*i/100;
                        c[1]=3*i%10%10;
                        c[2]=3*i%100/10;
                        c[3]=3*i/100;
                        if(a[1]*a[2]*a[3]*b[1]*b[2]*b[3]*c[1]*c[2]*c[3]==362880&&a[1]+a[2]+a[3]+b[1]+b[2]+b[3]+c[1]+c[2]+c[3]==45){
                            cout<<i<<" "<<i*2<<" "<<i*3<<endl;
                        }
                    }
                    return 0;
                }
                
                • -5

                  硬算的 #include<bits/stdc++.h> using namespace std; int main() { cout<<192<<" "<<384<<" "<<576<<endl; cout<<219<<" "<<438<<" "<<657<<endl; cout<<273<<" "<<546<<" "<<819<<endl; cout<<327<<" "<<654<<" "<<981<<endl; }

                • 1

                信息

                ID
                5066
                时间
                1000ms
                内存
                64MiB
                难度
                3
                标签
                递交数
                954
                已通过
                506
                上传者