题解 | #Old Bill#

Old Bill

http://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927

#include<iostream>
using namespace std;

int main(void) {
    int n;
    while (cin >> n) {
        int x, y, z;
        cin >> x >> y >> z;
        bool flag = true;
        for (int i = 9; i >= 1; i--) {
            for (int j = 9; j >= 0; j--) {
                int ans = i * 10000 + x * 1000 + y * 100 + z * 10 + j;
                if (ans / n * n == ans) {
                    flag = false;
                    cout << i << ' ' << j << ' ' << ans / n << endl;
                    break;
                }
            }
            if (!flag) break;
        }
        if (flag)    cout << 0 << endl;
    }
    return 0;
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务