結果

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

ソースコード

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;
        a += N / 123;
        b += N / 123;
        c += N / 123;
        N %= 123;
        if (N >= 111) c++, N -= 111;
        a += N / 12;
        b += N / 12;
        N %= 12;
        if (N >= 11) b++, N -= 11;
        a += N;
        int64_t total = a + b + c + d;
        for (int64_t v : {a, b, c, d}) {
            if (v * 2 >= total) a = -1;
        }
        if (a == -1) std::cout << -1 << std::endl;
        else std::cout << a << ' ' << b << ' ' << c << ' ' << d << std::endl;
    }
}
0