結果
| 問題 | No.653 E869120 and Lucky Numbers |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-23 11:12:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 546 bytes |
| 記録 | |
| コンパイル時間 | 1,829 ms |
| コンパイル使用メモリ | 192,468 KB |
| 最終ジャッジ日時 | 2025-01-11 09:32:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 2 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
string s; cin>>s;
int n=s.length();
assert(s[0]!='0');
reverse(s.begin(),s.end());
bool ok=true;
int phase=0,carry=0;
rep(i,n){
int a=s[i]-'0'-carry;
if(2<=a && a<=4){
if(phase!=0) ok=false;
carry=1;
}
else if(6<=a && a<=7){
if(phase==2 || i==0) ok=false;
phase=1;
carry=0;
}
else if(a==0){
if(phase!=0 || i==0) ok=false;
phase=2;
carry=0;
}
else ok=false;
}
puts(ok?"Yes":"No");
return 0;
}