結果
| 問題 | No.791 うし数列 | 
| コンテスト | |
| ユーザー |  dgd1724 | 
| 提出日時 | 2019-03-31 19:20:35 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 514 bytes | 
| コンパイル時間 | 657 ms | 
| コンパイル使用メモリ | 58,016 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 05:33:21 | 
| 合計ジャッジ時間 | 1,447 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 15 | 
ソースコード
#include <fstream>
#include <iostream>
#include <string>
int main() {
	//std::ifstream inf("Text.txt");	std::cin.rdbuf(inf.rdbuf());
	std::string S;
	std::cin >> S;
	int ans = 0;
	if (S[0] != '1') {
		std::cout << "-1" << std::endl;
		return 0;
	}
	if (S.length() == 1 && S[0] == '1') {
		std::cout << "-1" << std::endl;
		return 0;
	}
	for (unsigned int i = 1; i < S.length(); i++) {
		if (S[i] == '3') {
			ans++;
		}
		else {
			ans = -1;
			break;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}
            
            
            
        