結果

問題 No.791 うし数列
ユーザー Athena2911Athena2911
提出日時 2019-03-27 05:43:08
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 479 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 57,492 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 01:46:37
合計ジャッジ時間 1,405 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    int ans=0;
    cin>>a;
    if(a[0]=='1'){
        for(int i=1;i<a.size();i++){
            if(a[i]=='3'){
                ans++;
                if(i==a.size()-1){
                    cout<<ans<<endl;
                }
            }else{
                cout<<-1<<endl;
                break;
            }
        }
    }else{
        cout<<-1<<endl;
    }
    

}
0