結果

問題 No.3204 Permuted Integer
ユーザー tkykwtnb
提出日時 2025-07-18 22:36:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 81,228 KB
最終ジャッジ日時 2025-07-18 22:36:43
合計ジャッジ時間 9,032 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
T=int(input())
D=defaultdict(int)
for i in range(1,31623):
    C=[0 for _ in range(10)]
    A=list(str(i**2))
    for a in A:
        C[int(a)]+=1
    if tuple(C[1:]) not in D:
        D[tuple(C[1:])]=i**2
for _ in range(T):
    N=list(input())
    C=[0 for _ in range(10)]
    for n in N:
        C[int(n)]+=1
    ans=-1
    if tuple(C[1:]) in D:
        ans=D[tuple(C[1:])]
    print(ans)
0