結果

問題 No.653 E869120 and Lucky Numbers
ユーザー beet
提出日時 2018-12-22 19:58:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 194,084 KB
最終ジャッジ日時 2025-01-06 19:53:34
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  int c=0,x=2;
  auto NO=[](){cout<<"No"<<endl;exit(0);};
  
  for(int i=0;i<(int)s.size();i++){
    int k=s[i]-'0';
    if(c) k--;    
    if(k<0) NO();
    int nx=-1;
    if(k==0) c=0,nx=0;
    if(k==6) c=0,nx=1;
    if(k==7) c=0,nx=1;
    
    if(k==2) c=1,nx=2;
    if(k==3) c=1,nx=2;
    if(k==4) c=1,nx=2;

    if(nx<0||x<nx) NO();
    x=nx;
    if(i==0&&x!=2) NO();
  }
  if(c) NO();
  cout<<"Yes"<<endl;
  return 0;
}
0