結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:28:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 595 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 208,736 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-18 21:28:20 |
合計ジャッジ時間 | 6,141 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int t; cin >> t; map<string, int> mp; for (int i = 1; i * i <= 1e9; i++){ string S = to_string(i * i); sort(S.rbegin(), S.rend()); while (S.back() == '0'){ S.pop_back(); } if (mp.count(S) == 0){ mp[S] = i * i; } } while (t--)[&]{ string N; cin >> N; int ans = 2e9; sort(N.rbegin(), N.rend()); while (N.back() == '0'){ N.pop_back(); } if (mp.count(N) > 0){ ans = mp[N]; } if (ans == 2e9){ ans = -1; } cout << ans << endl; }(); }