题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include <iostream>
using namespace std;
int main() {
int a, b;
int n,x,y,z;
int price=0;
int flag=1;
while (cin >>n>>x>>y>>z) { // 注意 while 处理多个
flag=1;
for(a=9;a>0&&flag==1;a--)
{
for(b=9;b>=0&&flag==1;b--)
{
price=0;
if((a*10000+x*1000+y*100+z*10+b)%n==0)
{
price=(a*10000+x*1000+y*100+z*10+b)/n;
cout<<a<<" "<<b<<" "<<price<<endl;
}
if(price!=0)flag=0;
}
}
if(price==0)cout<<"0"<<endl;
}
}
// 使用状态标志位flag巧妙设计跳出双重循环

