結果

問題 No.3204 Permuted Integer
ユーザー dvasgdjhas
提出日時 2025-07-18 21:42:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 597 bytes
コンパイル時間 2,923 ms
コンパイル使用メモリ 282,524 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-18 21:42:51
合計ジャッジ時間 7,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
 
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        string s = to_string(n);
        sort(s.begin(),s.end());
        bool f=0;
        do{
            int x = stoi(s);
            int y = sqrt(x);
            if(y*y == x){
                cout<<x<<endl;
                f=1;
                break;
            }
        }while(next_permutation(s.begin(),s.end()));
        if(f==0)cout<<-1<<endl;
    }
    return 0;
}
0