結果
| 問題 | No.791 うし数列 | 
| コンテスト | |
| ユーザー |  Konton7 | 
| 提出日時 | 2019-11-26 22:43:07 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 410 bytes | 
| コンパイル時間 | 792 ms | 
| コンパイル使用メモリ | 71,312 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-07 00:59:31 | 
| 合計ジャッジ時間 | 1,262 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    string s;
  	cin >> s;
    int n = s.size();
    int ans = 0;
    for ( int i = 0; i < n; i ++ ) {
        if ( i == 0 && s[i] != '1' ) ans = -1;
        else if ( i > 0 && s[i] != '3' ) ans = -1;
    }
    if ( ans != -1 && n > 1 ) ans = n-1;
  	if ( ans == 0 ) ans = -1;
    cout << ans << endl;
    return 0;
}
            
            
            
        