結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 21:32:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 590 bytes |
| コンパイル時間 | 244 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 86,848 KB |
| 最終ジャッジ日時 | 2025-07-18 21:33:18 |
| 合計ジャッジ時間 | 13,079 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 15 |
ソースコード
from collections import defaultdict
t = int(input())
d = defaultdict(lambda: float('inf'))
for i in range(1, 100000):
s = str(i*i)
l = [0]*10
for c in s:
if int(c) != 0:
l[int(c)] += 1
d[tuple(l)] = min(d[tuple(l)], i)
for _ in range(t):
n = int(input())
lis = [0]*10
for c in str(n):
lis[int(c)] += 1
ans = float('inf')
for i in range(lis[0]+1):
lis2 = [i]+lis[1:]
if tuple(lis2) in d:
ans = min(ans, d[tuple(lis2)])
if ans == float('inf'):
print(-1)
else:
print(ans*ans)