結果

問題 No.3245 Payment with 8-rep Currency
コンテスト
ユーザー detteiuu
提出日時 2026-08-24 22:46:35
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 204 ms / 2,000 ms
+ 407µs
コード長 903 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 96,096 KB
実行使用メモリ 86,128 KB
最終ジャッジ日時 2026-08-24 22:46:52
合計ジャッジ時間 11,224 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

A = [None for _ in range(12)]
B = [None for _ in range(592)]
for a in range(41):
    for b in range(41):
        for c in range(41):
            for d in range(41):
                s = a+b+c+d
                s2 = a+b*11+c*111+d*1111
                if max(a, b, c, d) < (s+1)//2:
                    if s2 <= 591 and B[s2] is None:
                        B[s2] = (a, b, c, d)
                    if A[s2%12] is None or s2 < A[s2%12][0]:
                        A[s2%12] = (s2, a, b, c, d)

for _ in range(int(input())):
    N = int(input())

    if N%8 != 0:
        print(-1)
        continue
    N //= 8

    if N <= 591:
        if B[N] is not None:
            print(*B[N])
        else:
            print(-1)
    else:
        ans = list(A[N%12][1:])
        diff = (N-A[N%12][0])//12
        ans[0] += diff
        ans[1] += diff
        print(*ans)
0