結果

問題 No.40 多項式の割り算
ユーザー MiyamonYMiyamonY
提出日時 2019-09-06 19:02:04
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 755 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 5,236 KB
実行使用メモリ 13,948 KB
最終ジャッジ日時 2023-09-06 14:27:48
合計ジャッジ時間 2,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
11,892 KB
testcase_01 AC 14 ms
11,752 KB
testcase_02 AC 14 ms
11,716 KB
testcase_03 AC 15 ms
11,788 KB
testcase_04 AC 18 ms
13,044 KB
testcase_05 AC 19 ms
13,628 KB
testcase_06 AC 28 ms
13,804 KB
testcase_07 AC 28 ms
13,884 KB
testcase_08 AC 16 ms
13,796 KB
testcase_09 AC 18 ms
13,232 KB
testcase_10 AC 27 ms
13,892 KB
testcase_11 AC 19 ms
12,864 KB
testcase_12 AC 16 ms
12,488 KB
testcase_13 AC 20 ms
13,948 KB
testcase_14 AC 18 ms
13,092 KB
testcase_15 AC 17 ms
13,104 KB
testcase_16 AC 23 ms
13,748 KB
testcase_17 AC 17 ms
12,288 KB
testcase_18 AC 19 ms
13,740 KB
testcase_19 AC 28 ms
13,884 KB
testcase_20 AC 16 ms
12,780 KB
testcase_21 AC 15 ms
12,252 KB
testcase_22 AC 15 ms
12,064 KB
testcase_23 AC 16 ms
12,752 KB
testcase_24 AC 19 ms
13,424 KB
testcase_25 AC 15 ms
11,700 KB
testcase_26 AC 14 ms
11,664 KB
testcase_27 AC 13 ms
11,776 KB
testcase_28 AC 14 ms
11,776 KB
testcase_29 AC 14 ms
11,828 KB
testcase_30 AC 15 ms
11,776 KB
testcase_31 AC 14 ms
11,744 KB
testcase_32 AC 15 ms
11,752 KB
testcase_33 AC 14 ms
11,700 KB
testcase_34 AC 14 ms
11,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (take-while-right list pred)
  (define (take-while list)
    (cond ((null? list) '())
	  ((pred (car list)) (take-while (cdr list)))
	  (else list)))
  (reverse (take-while (reverse list))))

(let* ((d (string->number (read-line)))
       (arr (list->vector (map string->number (string-split (read-line) #\space)))))

  (let loop ((i d))
    (cond ((< i 3) arr)
	  (else
	   (let1 c (vector-ref arr i)
		 (vector-set! arr i 0)
		 (vector-set! arr (- i 2) (- (vector-ref arr (- i 2)) (* -1 c))))
	   (loop (- i 1)))))

  (let1 lis (take-while-right (vector->list arr) (lambda (x) (= 0 x)))
	(cond ((= (length lis) 0) (print 0) (print 0))
	      (else
	       (print (- (length lis) 1))
	       (print (string-join (map number->string lis)" "))))))
0