結果

問題 No.40 多項式の割り算
ユーザー Maboy
提出日時 2021-06-23 10:02:07
言語 Swift
(6.0.3)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 7,914 ms
コンパイル使用メモリ 139,348 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-06-24 06:19:10
合計ジャッジ時間 7,778 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

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