結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 21:28:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 591 bytes |
| コンパイル時間 | 2,965 ms |
| コンパイル使用メモリ | 286,288 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2025-07-18 23:35:28 |
| 合計ジャッジ時間 | 5,745 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
signed main(){
cin.tie(0)->sync_with_stdio(0);
map<vector<int>,int>mp;
for(int i=1;i*i<=1'000'000'000;++i){
vector<int>cnt(10);
int n=i*i;
while(n){
++cnt[n%10];
n/=10;
}
if(mp.find(cnt)==mp.end()){
mp[cnt]=i*i;
}
}
int t;cin>>t;
while(t--){
int N;cin>>N;
int ans=1<<30;
vector<int>cnt(10);
while(N){
++cnt[N%10];
N/=10;
}
for(;0<=cnt[0];--cnt[0]){
int v=mp[cnt];
if(v)ans=min(ans,v);
}
if(ans==1<<30)ans=-1;
cout<<ans<<'\n';
}
}