为什么只有80啊!最后一个点过不了,大佬看下!!

P1618 三连击(升级版)

Dayspring @ 2019-07-22 23:07:40

include <iostream>

using namespace std;

int q; int main() { int a,b,c,x,y,ib,is,ig,xb,xs,xg,yb,ys,yg; cin>>a>>b>>c; for(int i=100;i<=999;i++){ if(ib/a<=999&&ic<=999){ x=ib/a; y=ic/a; ib=i/100; is=(i-ib100)/10; ig=(i-ib100-is10); xb=x/100; xs=(x-xb100)/10; xg=x-xb100-xs10; yb=y/100; ys=(y-yb100)/10; yg=(y-yb100-ys10); if((ib+is+ig+xb+xg+xs+yb+ys+yg==45)&&(ibisigxsxbxgysybyg==12345678*9)){ cout<<i<<" "<<x<<" "<<y<<endl; q=1; } } } if(q==0){ cout<<"No!!!";} return 0; }


by 赫敏·东方延绪 @ 2019-07-22 23:10:03

希望更丰富的展现?使用Markdown

不记得说第几次了。。


by 赫敏·东方延绪 @ 2019-07-22 23:10:32

@Dayspring


by 固执 @ 2019-07-22 23:55:42

希望更丰富的展现?使用Markdown


by Dayspring @ 2019-07-23 21:27:17

#include <iostream>
using namespace std;

int q;
int main()
{
    int a,b,c,x,y,ib,is,ig,xb,xs,xg,yb,ys,yg;
    cin>>a>>b>>c;
    for(int i=100;i<=999;i++){
        if(i*b/a<=999&&i*c<=999){
            x=i*b/a;
            y=i*c/a;
            ib=i/100;
            is=(i-ib*100)/10;
            ig=(i-ib*100-is*10);
            xb=x/100;
            xs=(x-xb*100)/10;
            xg=x-xb*100-xs*10;
            yb=y/100;
            ys=(y-yb*100)/10;
            yg=(y-yb*100-ys*10);
            if((ib+is+ig+xb+xg+xs+yb+ys+yg==45)&&(ib*is*ig*xs*xb*xg*ys*yb*yg==1*2*3*4*5*6*7*8*9)){
            cout<<i<<" "<<x<<" "<<y<<endl;
            q=1;
        } 
        }
    } if(q==0){
    cout<<"No!!!";}
    return 0;
}

@赫敏·东方延绪 帮忙看下,谢谢啦!!!


by 赫敏·东方延绪 @ 2019-07-24 08:38:08

@Dayspring 要先判断i是否为a的倍数


by Dayspring @ 2019-07-24 20:28:40

@赫敏·东方延绪 谢谢啦!!!


by itachi_moon @ 2019-08-13 15:59:29

if(ib/a<=999&&ic<=999) 改为 if(ib/a<=999&&ic/a<=999) 吧!


|