結果

問題 No.40 多項式の割り算
ユーザー MaboyMaboy
提出日時 2021-06-23 10:02:07
言語 Swift
(5.10.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 3,828 ms
コンパイル使用メモリ 141,004 KB
実行使用メモリ 8,480 KB
最終ジャッジ日時 2023-09-06 11:42:39
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,348 KB
testcase_01 AC 3 ms
8,280 KB
testcase_02 AC 3 ms
8,216 KB
testcase_03 AC 3 ms
8,216 KB
testcase_04 AC 8 ms
8,312 KB
testcase_05 AC 9 ms
8,404 KB
testcase_06 AC 11 ms
8,480 KB
testcase_07 AC 11 ms
8,452 KB
testcase_08 AC 4 ms
8,180 KB
testcase_09 AC 9 ms
8,440 KB
testcase_10 AC 10 ms
8,372 KB
testcase_11 AC 7 ms
8,304 KB
testcase_12 AC 6 ms
8,284 KB
testcase_13 AC 10 ms
8,428 KB
testcase_14 AC 8 ms
8,464 KB
testcase_15 AC 7 ms
8,372 KB
testcase_16 AC 10 ms
8,384 KB
testcase_17 AC 5 ms
8,408 KB
testcase_18 AC 9 ms
8,328 KB
testcase_19 AC 11 ms
8,404 KB
testcase_20 AC 6 ms
8,448 KB
testcase_21 AC 5 ms
8,384 KB
testcase_22 AC 4 ms
8,268 KB
testcase_23 AC 7 ms
8,328 KB
testcase_24 AC 9 ms
8,320 KB
testcase_25 AC 3 ms
8,220 KB
testcase_26 AC 3 ms
8,192 KB
testcase_27 AC 3 ms
8,216 KB
testcase_28 AC 3 ms
8,180 KB
testcase_29 AC 3 ms
8,216 KB
testcase_30 AC 3 ms
8,280 KB
testcase_31 AC 3 ms
8,348 KB
testcase_32 AC 3 ms
8,240 KB
testcase_33 AC 3 ms
8,252 KB
testcase_34 AC 3 ms
8,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let n = Int(readLine()!)!
var a = readLine()!.split(separator: " ").map{Int($0)!}+[0,0]

if n != 0{
    for i in (3...n).sorted(by: >){
        a[i-2]+=a[i]
    }
    if a[2] != 0{
        print(2)
        print(a[..<3].map{String($0)}.joined(separator: " "))
    }else if a[1] != 0{
        print(1)
        print(a[..<2].map{String($0)}.joined(separator: " "))
    }else{
        print(0)
        print(a[0])
    }
}else{
    print(n)
    print(a[0])
}
0