結果

問題 No.653 E869120 and Lucky Numbers
ユーザー wild
提出日時 2018-02-24 00:19:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,096 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 75,916 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-10 06:44:47
合計ジャッジ時間 1,770 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  string s;
  cin >> s;

  int last = s[s.length() - 1] - '0';
  if (!(last == 2 || last == 3 || last == 4)){
    cout << "No" << endl;
    return 0;
  }

  bool c = true;
  bool pre = false;
  int current;
  for (int i = s.length() - 2; i>-1; i--) {
    current = s[i] - '0';
    if(!c) {
      if (pre) {
        if (!(current == 7 || current == 8)) {
          cout << "No" << endl;
          return 0;
        }

        pre = true;
        continue;
      }
      if (!(current == 6 || current == 7)) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (!(current == 3 || current == 4 || current == 5)) {
        if (i==0 && (current == 7 || current == 8 || current == 1)) {
          cout << "Yes" << endl;
          return 0;
        } else if (i==0) {
          cout << "No" << endl;
          return 0;
        }
        c = false;
        pre = true;
      }
    }
  }
  cout << "Yes" << endl;
}
0