結果

問題 No.3204 Permuted Integer
コンテスト
ユーザー SPD_9X2
提出日時 2025-07-19 02:56:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 284 ms / 2,000 ms
+ 969µs
コード長 503 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 237 ms
コンパイル使用メモリ 96,112 KB
実行使用メモリ 90,588 KB
最終ジャッジ日時 2026-07-13 09:24:19
合計ジャッジ時間 7,512 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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