結果

問題 No.3204 Permuted Integer
ユーザー 👑 SPD_9X2
提出日時 2025-07-19 02:56:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 441 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 82,924 KB
最終ジャッジ日時 2025-07-19 02:56:59
合計ジャッジ時間 9,017 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

dic = {}

for i in range(1,31700):
    x = i*i

    s = [0] * 10

    while x:
        s[x%10] += 1
        x //= 10

    stup = tuple(s)
    if stup not in dic:
        dic[stup] = i*i

TT = int(input())

for _ in range(TT):

    N = int(input())

    s = [0] * 10

    x = N
    while x:
        s[x % 10] += 1
        x //= 10

    for i in range(s[0]+1):
        s[0] = i
        stup = tuple(s)

        if stup in dic:
            print (dic[stup])
            break
    else:
        print (-1)
0