結果

問題 No.39 桁の数字を入れ替え
ユーザー MiyamonYMiyamonY
提出日時 2019-09-06 01:59:53
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 15,448 KB
最終ジャッジ日時 2023-09-05 06:40:16
合計ジャッジ時間 2,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
15,252 KB
testcase_01 AC 48 ms
15,328 KB
testcase_02 AC 47 ms
15,432 KB
testcase_03 AC 47 ms
15,332 KB
testcase_04 AC 46 ms
15,308 KB
testcase_05 AC 48 ms
15,324 KB
testcase_06 AC 48 ms
15,348 KB
testcase_07 AC 48 ms
15,448 KB
testcase_08 AC 47 ms
15,292 KB
testcase_09 AC 47 ms
15,276 KB
testcase_10 AC 47 ms
15,440 KB
testcase_11 AC 47 ms
15,412 KB
testcase_12 AC 47 ms
15,260 KB
testcase_13 AC 47 ms
15,404 KB
testcase_14 AC 47 ms
15,356 KB
testcase_15 AC 47 ms
15,324 KB
testcase_16 AC 48 ms
15,436 KB
testcase_17 AC 47 ms
15,416 KB
testcase_18 AC 48 ms
15,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

(let* ((n (read)))
  (define vec (vector-map char->integer (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 (list->string (map integer->char vec-copied)))
					    (loop (cdr is)))))))))))
0