結果

問題 No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2)
ユーザー tamatotamato
提出日時 2021-11-05 23:28:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 57,984 KB
最終ジャッジ日時 2024-04-24 07:26:03
合計ジャッジ時間 1,011 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
57,472 KB
testcase_01 AC 42 ms
57,344 KB
testcase_02 AC 43 ms
57,856 KB
testcase_03 AC 42 ms
57,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    L = {}
    L1 = {}
    L2 = {}
    for i in range(10, 16):
        n1 = i
        cnt1 = [0] * 8
        while n1:
            cnt1[n1 % 8] += 1
            n1 //= 8
        L1[tuple(cnt1)] = i
        for j in range(10, 16):
            n2 = i * 16 + j
            cnt2 = [0] * 8
            while n2:
                cnt2[n2 % 8] += 1
                n2 //= 8
            L2[tuple(cnt2)] = (i, j)
            for k in range(10, 16):
                n = i * (16**2) + j * 16 + k
                cnt = [0] * 8
                while n:
                    cnt[n%8] += 1
                    n //= 8
                L[tuple(cnt)] = (i, j, k)

    ANS7 = "CEEAC"
    ANS14 = "BBCCCFACAC"
    ANS28 = "ACCACCCCCCCCABACAAFFE"

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

        M = (N // 3) * 4
        if N % 3 == 1:
            M += 2
        elif N % 3 == 2:
            M += 3
        if M % 7:
            print(-1)
            continue

        ans = [ANS28] * (M // 28)
        if M % 28 == 7:
            ans = [ANS7] + ans
        elif M % 28 == 14:
            ans = [ANS14] + ans
        print("".join(ans))


if __name__ == '__main__':
    main()
0