結果

問題 No.653 E869120 and Lucky Numbers
ユーザー pekempey
提出日時 2018-02-23 22:41:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 70,528 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-09 19:59:42
合計ジャッジ時間 1,576 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>

using namespace std;

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

  int carry = 0;
  int bad = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    for (int x : {0, 6, 7}) {
      for (int y : {0, 6, 7}) {
        if (i == s.size() - 1 && (x == 0 || y == 0)) continue;
        if (bad == 1 && y != 0) continue;
        if (bad == 2 && (x != 0 || y != 0)) continue;
        if ((x + y + carry) % 10 == s[i] - '0') {
          if (x == 0) bad++;
          if (y == 0) bad++;
          carry = (x + y + carry) / 10;
          goto LP;
        }
      }
    }
    cout << "No" << endl;
    return 0;
LP:;
  }
  if (carry == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0