結果

問題 No.39 桁の数字を入れ替え
ユーザー MiyamonYMiyamonY
提出日時 2019-09-06 02:03:17
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 15,504 KB
最終ジャッジ日時 2023-09-05 06:45:19
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
15,252 KB
testcase_01 AC 44 ms
15,308 KB
testcase_02 AC 44 ms
15,464 KB
testcase_03 AC 43 ms
15,240 KB
testcase_04 AC 43 ms
15,248 KB
testcase_05 AC 43 ms
15,432 KB
testcase_06 AC 45 ms
15,208 KB
testcase_07 AC 45 ms
15,504 KB
testcase_08 AC 44 ms
15,472 KB
testcase_09 AC 43 ms
15,336 KB
testcase_10 AC 45 ms
15,432 KB
testcase_11 AC 44 ms
15,244 KB
testcase_12 AC 44 ms
15,456 KB
testcase_13 AC 44 ms
15,336 KB
testcase_14 AC 43 ms
15,224 KB
testcase_15 AC 44 ms
15,240 KB
testcase_16 AC 44 ms
15,340 KB
testcase_17 AC 45 ms
15,288 KB
testcase_18 AC 44 ms
15,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(use scheme.vector)
(use gauche.collection)
(use util.combinations)

(let* ((n (read)))
  (define vec (string->vector (number->string n)))
  (print (apply max
		(cons n #?=(let loop ((is (combinations (iota (vector-length vec)) 2)))
			     (cond ((null? is) '())
				   (else
				    (let ((vec-copied (vector-copy vec))
					  (pair (car is)))
				      (vector-swap! vec-copied (car pair) (cadr pair))
				      (cons (string->number (vector->string vec-copied))
					    (loop (cdr is)))))))))))
0