結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2025-07-18 21:29:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,527 ms / 2,000 ms |
| コード長 | 561 bytes |
| コンパイル時間 | 404 ms |
| コンパイル使用メモリ | 82,532 KB |
| 実行使用メモリ | 136,872 KB |
| 最終ジャッジ日時 | 2025-07-18 23:36:25 |
| 合計ジャッジ時間 | 37,942 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
t = int(input())
C = [{} for _ in range(10)]
N = 10 ** 5
for i in range(1, N):
now = i * i
now = str(now)
cnt = now.count("0")
L = [j for j in now if j != "0"]
L.sort()
L = tuple(L)
for j in range(cnt, 10):
if not L in C[j]:
C[j][L] = int(now)
else:
C[j][L] = min(C[j][L], int(now))
for _ in range(t):
n = int(input())
cnt = str(n).count("0")
L = [j for j in str(n) if j != "0"]
L.sort()
L = tuple(L)
if L in C[cnt]:
print(C[cnt][L])
else:
print(-1)
kidodesu