ACM.简单问题。搞不定。高手帮忙。
小弟新手。
题在这里。
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679
Sample Input
3
72
6 7 9
5
2 3 7
78
0 0 5
Sample Output
3 2 511
9 5 18475
0
运行无错。
但是提交之后就是Wrong Answer。
我得代码。
#include <iostream>using namespace std;int main(){ int count = 0; cin>>count; int N[1000], x[1000], y[1000],z[1000]; int f = 9,l = 9; int sum= 0; for(int i = 0; i < count; i++) { cin>>N[i]; cin>>x[i]>>y[i]>>z[i]; } for(int j = 0; j < count; j++) { for(f = 9; f > 0; f--) { for(l = 9; l >= 0; l--) { sum = 10000*f + 1000*x[j] + 100*y[j] + 10*z[j] + 1*l; if(0 == sum % N[j]) { int result = 0; result = sum / N[j]; cout<<f<<" "<<l<<" "<<result<<endl; break; } } if(0 == sum % N[j]) { break; } } if(0 != sum % N[j]) { cout<<0<<endl; } } return 0;}