結果

問題 No.3245 Payment with 8-rep Currency
ユーザー iastm
提出日時 2025-08-22 22:20:50
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-22 22:21:03
合計ジャッジ時間 11,655 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int main() {
    int T;
    std::cin >> T;
    while (T--) {
        int64_t N;
        std::cin >> N;
        if (N % 8 > 0) {
            std::cout << -1 << std::endl;
            continue;
        }

        N /= 8;
        int64_t a = N / 1234;
        int64_t b = N / 1234;
        int64_t c = N / 1234;
        int64_t d = N / 1234;
        N %= 1234;
        if (N >= 1111) d++, N -= 1111;

        bool found = false;
        for (int x = 0; x * 1 <= N; x++) {
            if (found) break;
            for (int y = 0; x * 1 + y * 11 <= N; y++) {
                if ((N - x * 1 - y * 11) % 111 > 0) continue;
                int z = (N - x * 1 - y * 11) / 111;
                int64_t total = a + b + c + d + x + y + z;
                if ((a + x) * 2 >= total) continue;
                if ((b + y) * 2 >= total) continue;
                if ((c + z) * 2 >= total) continue;
                if (d * 2 >= total) continue;
                std::cout << a + x << ' ' << b + y << ' ' << c + z << ' ' << d << std::endl;
                found = true;
                break;
            }
        }

        if (!found) std::cout << -1 << std::endl;
    }
}
0