3 条题解

  • 1
    @ 2025-2-10 20:07:56

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

    思路

    这题只需要枚举a,b,c a,b,c 的值就行了,然后把数字拆分后用桶的思想挨个检查即可。 至于a的枚举范围从最小(123)到 1000/3 就行。 一定记得清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
    */
    
    • 0

      硬算的 #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; }

    • 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

    • 1

    信息

    ID
    5066
    时间
    1000ms
    内存
    64MiB
    难度
    2
    标签
    递交数
    594
    已通过
    319
    上传者