結果

問題 No.791 うし数列
ユーザー keib
提出日時 2019-03-05 13:40:26
言語 Swift
(6.0.3)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 263 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 170,732 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-11-30 13:40:12
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation 

let s = readLine()!
if s.count <= 1 {
    print(-1)
    exit(0)    
}

if s.prefix(1) != "1" {
    print(-1)
    exit(0)    
}

if s.suffix(s.count - 1).first(where: { $0 != "3" }) != nil {
    print(-1)
    exit(0)    
} 

print(s.count - 1)
0