题解 | #Old bill#

Old bill

https://ac.nowcoder.com/acm/problem/119723

牛客网的uvalive提交姬炸了,自行去某神秘网站提交即可。 思路:c语言模拟,读懂题就行了。

#include<iostream>
using namespace std;

int main(void) {
    int t;
    cin >> t;
    while (t--) {
        int n;
        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;
}
全部评论

相关推荐

coffrar:全都是已读😅沟通一千五百多个了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务