結果

問題 No.3245 Payment with 8-rep Currency
ユーザー Kude
提出日時 2025-08-22 23:03:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2025-08-22 23:04:18
合計ジャッジ時間 16,025 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

seen = [None] * (2222 + 1)
for i in range(1, 30):
    for j in range(1, 40):
        for k in range(1, 20):
            v = i * 1 + j * 11 + k * 111
            if v > 2222:
                break
            if 2 * max(i, j, k) >= i + j + k:
                continue
            seen[v] = (i, j, k)

# cnt = 0
# for v in range(2222 + 1):
#     if not seen[v]:
#         print(v)
#         cnt += 1
# print(cnt)
# exit()
# print(seen[1111])
for _ in range(int(input())):
    n = int(input())
    if n % 8:
        print(-1)
        continue
    n //= 8
    if n <= 2222:
        if not seen[n]:
            print(-1)
        else:
            print(*seen[n], 0)
        continue
    # n - 1111x <= 2222
    # 1111x >= n - 2222
    x = (n - 2222 + 1110) // 1111
    assert 1111 <= n - 1111 * x <= 2222
    ans = list(seen[n - 1111 * x])
    for i in range(3):
        ans[i] += seen[1111][i] * x
    assert ans[0] * 1 + ans[1] * 11 + ans[2] * 111 == n
    assert 2 * max(ans) < sum(ans)
    print(*ans, 0)
0