結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-23 11:04:53 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 518 bytes | 
| コンパイル時間 | 2,645 ms | 
| コンパイル使用メモリ | 191,896 KB | 
| 最終ジャッジ日時 | 2025-01-11 09:32:23 | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 WA * 2 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	string s; cin>>s;
	int n=s.length();
	reverse(s.begin(),s.end());
	bool ok=true;
	int phase=0,carry=0;
	rep(i,n){
		int a=s[i]-'0'-carry;
		if(2<=a && a<=4){
			if(phase!=0) ok=false;
			carry=1;
		}
		else if(6<=a && a<=7){
			if(phase==2 || i==0) ok=false;
			phase=1;
			carry=0;
		}
		else if(a==0){
			if(phase!=0) ok=false;
			phase=2;
			carry=0;
		}
		else ok=false;
	}
	puts(ok?"Yes":"No");
	return 0;
}
            
            
            
        