結果
| 問題 | No.3204 Permuted Integer |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-07-19 17:42:58 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 309 ms |
| コンパイル使用メモリ | 74,048 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-13 09:35:25 |
| 合計ジャッジ時間 | 4,207 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 25 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3204.cc: No.3204 Permuted Integer - yukicoder
*/
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_M = 10;
/* typedef */
/* global variables */
int ps[MAX_M];
/* subroutines */
/* main */
int main() {
int tn;
scanf("%d", &tn);
while (tn--) {
int n;
scanf("%d", &n);
int m = 0;
while (n > 0) ps[m++] = n % 10, n /= 10;
sort(ps, ps + m);
int minx = -1;
do {
int x = 0;
for (int i = 0; i < m; i++) x = x * 10 + ps[i];
int y = sqrt(0.5 + x);
if (y * y == x) { minx = x; break; }
} while (next_permutation(ps, ps + m));
printf("%d\n", minx);
}
return 0;
}
tnakao0123