結果

問題 No.791 うし数列
コンテスト
ユーザー sorag
提出日時 2022-08-16 22:59:08
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 334µs
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 404 ms
コンパイル使用メモリ 94,892 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-09-09 18:41:37
合計ジャッジ時間 1,839 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include<string>
#include<queue>
#include<math.h>
#define pb push_back
#define all(x) begin(x),end(x)
#define ll long long
#define P pair<int,int>
#define lP pait<ll,ll>
using namespace std;
int main() {
    bool f=0;
    int cnt=0;
    string n;
    cin>>n;
    if(n.size()==1) f=1;
    if(n[0]!='1') f=1;
    for(int i=1;i<n.size();i++){
        if(n[i]=='3') cnt++;
        else if(n[i]!='3') f=1;
    }
    if(f) cout<<-1<<endl;
    else cout<<cnt<<endl;
    return 0;
}
  
    

0