結果

問題 No.3204 Permuted Integer
ユーザー sasa8uyauya
提出日時 2025-07-18 21:25:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 591 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 82,968 KB
実行使用メモリ 91,452 KB
最終ジャッジ日時 2025-07-18 23:34:45
合計ジャッジ時間 12,233 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

d={}
for i in range(1,100000):
  s=str(i**2)
  c=[0]*10
  for v in s:
    c[int(v)]+=1
  c=tuple(c)
  if c not in d:
    d[c]=i**2
T=int(input())
for _ in range(T):
  n=input()
  c=[0]*10
  for v in n:
    c[int(v)]+=1
  X=10**10
  ans=X
  while c[0]>=0:
    if tuple(c) in d:
      ans=min(ans,d[tuple(c)])
    c[0]-=1
  print(ans if ans<X else -1)
0