結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:40:05 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,379 bytes |
コンパイル時間 | 3,531 ms |
コンパイル使用メモリ | 287,688 KB |
実行使用メモリ | 17,408 KB |
最終ジャッジ日時 | 2025-07-18 21:41:05 |
合計ジャッジ時間 | 27,144 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; /* ショトカ登録 cin cout endl return int double string char pair make_pair first second tuple make_tuple sort erase swap stoi to_string auto bool true false vector queue priority_queue front pop_frpnt size substr push_back pop_back push pop top if for while break continue next_permutation __builtin_popcount */ //無限 int inf = 1020304050; int64_t INF = 1020304050607080900; //モッド int64_t mod = 998244353; //all マクロ #define all(v) v.begin(), v.end() int main () { //少数以下 cout << fixed << setprecision(15); map<vector<int64_t>, int64_t> M; for (int64_t i = 1; i < 1000000; i++) { vector<int64_t> l(9, 0); int64_t j = i * i; string s = to_string(j); for (auto x : s) { int64_t k = x - '0'; if (k == 0) continue; l[k - 1]++; } if (M.count(l) == 0) { M[l] = j; } } int64_t TT; cin >> TT; for (int64_t tt = 0; tt < TT; tt++) { int64_t N; cin >> N; string S = to_string(N); vector<int64_t> L(9, 0); for (auto x : S) { int64_t k = x - '0'; if (k == 0) continue; L[k - 1]++; } if (M.count(L) == 0) cout << -1 << endl; else { cout << M.at(L) << endl; } } }