結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:37:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,333 bytes |
コンパイル時間 | 3,644 ms |
コンパイル使用メモリ | 288,564 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-18 21:38:21 |
合計ジャッジ時間 | 8,771 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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<int>, int> M; for (int i = 1; i < 40000; i++) { vector<int> l(9, 0); int j = i * i; string s = to_string(j); for (auto x : s) { int k = x - '0'; if (k == 0) continue; l[k - 1]++; } if (M.count(l) == 0) { M[l] = j; } } int TT; cin >> TT; for (int tt = 0; tt < TT; tt++) { int N; cin >> N; string S = to_string(N); vector<int> L(9, 0); for (auto x : S) { int k = x - '0'; if (k == 0) continue; L[k - 1]++; } if (M.count(L) == 0) cout << -1 << endl; else { cout << M.at(L) << endl; } } }