結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-19 17:42:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 699 ms |
コンパイル使用メモリ | 64,128 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-19 17:43:04 |
合計ジャッジ時間 | 6,279 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d", &tn); | ~~~~~^~~~~~~~~~~ main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- 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; }