結果

問題 No.791 うし数列
ユーザー Athena2911
提出日時 2019-03-27 05:45:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 57,464 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 01:47:04
合計ジャッジ時間 1,085 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    int ans=0;
    cin>>a;
    if(a=="1"){
        cout<<-1<<endl;
    }
    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