結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 21:41:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 478 ms / 2,000 ms |
| コード長 | 545 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 82,976 KB |
| 実行使用メモリ | 83,132 KB |
| 最終ジャッジ日時 | 2025-07-18 23:37:46 |
| 合計ジャッジ時間 | 9,629 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
d = {}
for i in range(1, 10**5):
if i * i > 10**9:
break
cnt = [0] * 10
s = str(i * i)
for c in s:
cnt[int(c)] += 1
if tuple(cnt) in d:
continue
d[tuple(cnt)] = i * i
for _ in range(int(input())):
N = int(input())
cnt = [0] * 10
ans = float("inf")
for c in str(N):
cnt[int(c)] += 1
t = cnt[0]
for i in range(t + 1):
cnt[0] = i
if tuple(cnt) in d:
ans = min(ans, d[tuple(cnt)])
if ans == float("inf"):
ans = -1
print(ans)