#include <iostream>
using namespace std;
bool is_magic(int n){
bool is_four = false;
int count = 0;
while(n/10){
int t = n%10;
if(t == 1){
is_four = false;
count = 0;
}
else if(t == 4){
is_four = true;
count++;
}
else
return false;
if( count >= 3)
return false;
n = n/10;
}
if(n != 1)
return false;
return true;
}
int main(){
int n;
cin>>n;
if(is_magic(n))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}
save
最新推荐文章于 2023-12-28 20:19:49 发布