結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:49:22 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 841 bytes |
コンパイル時間 | 1,372 ms |
コンパイル使用メモリ | 117,408 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-18 21:49:38 |
合計ジャッジ時間 | 5,822 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 15 |
ソースコード
#include <iostream> #include <unordered_map> #include <string> #include <algorithm> int main() { std::unordered_map<std::string, int> roots; for (int i = 1; i * i <= 1000000000; i++) { if (i % 10 == 0) continue; int sq = i * i; std::string s = std::to_string(sq); auto t = s; std::sort(t.rbegin(), t.rend()); while (t.back() == '0') t.pop_back(); if (!roots[t]) roots[t] = sq; } int T; std::cin >> T; while (T--) { std::string N; std::cin >> N; if (N.size() == 10) { std::cout << 1 << std::endl; continue; } std::sort(N.rbegin(), N.rend()); while (N.back() == '0') N.pop_back(); if (roots[N]) std::cout << roots[N] << std::endl; else std::cout << -1 << std::endl; } }