結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-07-28 01:07:46 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 799 bytes | 
| コンパイル時間 | 821 ms | 
| コンパイル使用メモリ | 70,400 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-13 18:19:28 | 
| 合計ジャッジ時間 | 1,879 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int carry = 0;
  bool bad[2] = {false, false};
  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[0] && x != 0) continue;
        if (bad[1] && y != 0) continue;
        if ((x + y + carry) % 10 == s[i] - '0') {
          if (x == 0) bad[0] = true;
          if (y == 0) bad[1] = true;
          carry = (x + y + carry) / 10;
          goto LP;
        }
      }
    }
    cout << "No" << endl;
    return 0;
LP:;
  }
  if (carry == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
            
            
            
        