Subtask #0 是过了,但是Subtask #1 过不了,求助大佬!

P1618 三连击(升级版)

acmwriter @ 2023-03-12 22:32:12

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=100;i<=999;i++){
        if(i%a==0){
            int d=i/a*b,e=i/a*c;
            if(d<=999&&e<=999){
                if(i/100+i/10%10+i%10+d/100+d/10%10+d%10+e/100+e/10%10+e%10==1+2+3+4+5+6+7+8+9&&(i/100)*(i/10%10)*(i%10)*(d/100)*(d/10%10)*(d%10)*(e/100)*(e/10%10)*(e%10)==1*2*3*4*5*6*7*8*9){
                cout<<i<<" "<<d<<" "<<e<<endl;
                ans++;
                }
                else continue;
            }
            else break;
        }
        else continue;
    }
    if(ans==0)cout<<"No!!!";
    return 0;
}

by GeorgeAAAADHD @ 2023-03-12 22:39:27

为什么要在分支结构里套 breakcontinue?


by acmwriter @ 2023-03-12 22:43:48

@GeorgeAAAADHD 不能套break 和 continue吗?


by GeorgeAAAADHD @ 2023-03-12 22:52:18

不能套 break

虽然还是不能过

明天帮你看吧。


by acmwriter @ 2023-03-12 22:52:58

@GeorgeAAAADHD 好的,感谢!


by StarLbright40 @ 2023-03-13 07:32:12

警惕 /0 惨案


by acmwriter @ 2023-03-13 09:31:18

@StarLbright40 感谢!过了!


|