結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  merom686 | 
| 提出日時 | 2018-02-23 22:55:05 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 964 bytes | 
| コンパイル時間 | 637 ms | 
| コンパイル使用メモリ | 74,280 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 18:15:15 | 
| 合計ジャッジ時間 | 1,659 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    string p;
    cin >> p;
    int n = p.size();
    int b = 0, s = 0, c = 0;
    for (int i = n - 1; i >= 0; i--) {
        int k = p[i] - '0' - c;
        if (s == 0) {
            if (k < 2 || 4 < k) {
                if (k == 6 || k == 7) {
                    if (i == n - 1) b = 1;
                    s = 1;
                    c = 0;
                } else if (k == 0) {
                    if (i != 0) b = 1;
                    c = 0;
                } else {
                    b = 1;
                }
            } else {
                c = 1;
            }
        } else {
            if (k == 6 || k == 7) {
                c = 0;
            } else {
                b = 1;
            }
        }
    }
    cout << (b == 0 && c == 0 ? "Yes" : "No") << endl;
    return 0;
}
            
            
            
        