結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-29 17:17:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 781 bytes |
コンパイル時間 | 2,111 ms |
コンパイル使用メモリ | 204,964 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-29 17:17:20 |
合計ジャッジ時間 | 5,114 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); map<string, int> mp; const int M = 1e9 + 5; for (int i = 1; i * i <= M; i++) { int num = i * i; string dig_cnt(10, '0'); int tot = 0; while (num > 0) { dig_cnt[num % 10]++; num /= 10; tot++; } while (tot < 10) { if (mp.find(dig_cnt) == mp.end()) { mp[dig_cnt] = i * i; } else { mp[dig_cnt] = min(mp[dig_cnt], i * i); } dig_cnt[0]++; tot++; } } int t; cin >> t; for (; t--;) { int n; cin >> n; string dig_cnt(10, '0'); while (n > 0) { dig_cnt[n % 10]++; n /= 10; } if (mp.count(dig_cnt)) { cout << mp[dig_cnt] << '\n'; } else { cout << -1 << '\n'; } } }