結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2025-07-23 15:36:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 711 bytes |
| コンパイル時間 | 1,562 ms |
| コンパイル使用メモリ | 172,944 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-07-23 15:36:10 |
| 合計ジャッジ時間 | 7,326 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:16: warning: overflow in conversion from ‘double’ to ‘ll’ {aka ‘long long int’} changes value from ‘9.9999999999999998e+108’ to ‘9223372036854775807’ [-Woverflow]
10 | ll n = 1e109;
| ^~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, n) for(int i = a; i < n; i++)
int main() {
int T;
cin >> T;
ll n = 1e109;
map<vector<int>, int> mp;
for(ll i = 1; i * i < n; i++) {
int sq = i * i;
vector<int> c(10);
while(sq) {
int d = sq % 10;
c[d]++;
sq /= 10;
}
if(mp.count(c)) mp[c] = min(mp[c], sq);
else mp[c] = sq;
}
rep(ti, 0, T) {
int N;
cin >> N;
int INF = 1e9 + 1;
vector<int> c(10);
while(N) {
int d = N % 10;
c[d]++;
N /= 10;
}
int ans = INF;
int r = c[0] + 1;
rep(i, 0, r) {
if(mp.count(c)) {
ans = min(ans, mp[c]);
c[0]--;
}
}
if(ans == INF) ans = -1;
cout << ans << endl;
}
}
forest3