結果

問題 No.653 E869120 and Lucky Numbers
ユーザー Ikom
提出日時 2018-02-23 23:24:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 2,204 ms
コンパイル使用メモリ 195,680 KB
最終ジャッジ日時 2025-01-05 08:32:42
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool flag = false;
bool ans = true;

int check(int a) {
    if (a == 2 || a == 3 || a == 4) return 1;
    else if (!flag && a==7 || a == 6) { flag = true; return 0;}
    else if (flag && a==7 || a == 6)  return 0;
    else return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    vector<int> p;
    for (int i = 0;i < s.size();i++){
        p.push_back(s[s.size() -i-1] - '0');
    }

    for (int i = 0;i < s.size()-1;i++){
        if (check(p[i]) >= 0) p[i+1] -= check(p[i]);
        else ans = false;
    }

    if (p[s.size() - 1] != 0) ans = false;

    cout << (ans? "Yes":"No") << endl;


    return 0;

}
0