結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-05-27 00:01:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 525 ms / 2,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 701 ms |
コンパイル使用メモリ | 82,844 KB |
実行使用メモリ | 101,076 KB |
最終ジャッジ日時 | 2025-07-18 23:34:20 |
合計ジャッジ時間 | 10,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
from collections import defaultdict INF = int(1e9) + 2525 d = defaultdict(lambda: INF) # count of digit 0-9 def get_frequency(value): c = [0] * 10 while value != 0: c[value % 10] += 1 value //= 10 return c x = 1 while x * x <= 10 ** 9: c = tuple(get_frequency(x * x)) d[c] = min(d[c], x * x) x += 1 T = int(input()) for _ in range(T): N = int(input()) c = get_frequency(N) ans = INF for i in range(c[0] + 1): ans = min(ans, d[tuple(c)]) c[0] -= 1 print(-1 if ans == INF else ans)