結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-18 21:37:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 921 bytes |
コンパイル時間 | 6,054 ms |
コンパイル使用メモリ | 334,748 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-18 21:37:27 |
合計ジャッジ時間 | 10,371 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 24 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main() { FAST_IO int T; cin >> T; while (T--) { string N; cin >> N; int n = N.size(); vector<int> a(n); iota(a.begin(), a.end(), 0); bool found = false; int mn = 1e9 + 10; do { int x = 0; for (int i = 0; i < n; ++i) { x = x * 10 + (N[a[i]] - '0'); } int sqX = sqrt(x); if (sqX * sqX == x) { mn = min(mn, sqX); found = true; } } while (next_permutation(a.begin(), a.end())); if (!found) { cout << -1 << endl; } else { cout << mn * mn << endl; } } }