题解 | #Old Bill#

Old Bill

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

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, x, y, z;
    while (scanf("%d%d%d%d", &n, &x, &y, &z) != EOF) {
        bool isOutput = false;
        for (int i = 9; i > 0; i--) {
            for (int j = 9; j >= 0; j--) {
                if ((i * 10000 + x * 1000 + y * 100 + z * 10 + j) % n == 0) {
                    isOutput = true;
                    printf("%d %d %d", i, j, (i * 10000 + x * 1000 + y * 100 + z * 10 + j) / n);
                    break;
                }
            }
            if (isOutput) {
                break;
            }
        }
        if (!isOutput) {
            printf("0");
        }
    }
    return 0;
//    sort(arr,arr+i,compare);
}

考研复试机试 文章被收录于专栏

考研复试机试

全部评论

相关推荐

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