zoukankan      html  css  js  c++  java
  • cf 320A

    A. Magic Numbers
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444,514 and 414 are not.

    You're given a number. Determine if it is a magic number or not.

    Input

    The first line of input contains an integer n(1 ≤ n ≤ 109). This number doesn't contain leading zeros.

    Output

    Print "YES" if n is a magic number or print "NO" if it's not.

    Sample test(s)
    input
    114114
    output
    YES
    input
    1111
    output
    YES
    input
    441231
    output
    NO
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    #include<queue>
    #include<set>
    #include<vector>
    using namespace std;
    #define INF 0xfffffff
    #define LL long long
    LL n;
    int main()
    {
         bool flag=false;
         scanf("%I64d",&n);
         while(n)
         {
               if(n%1000==144)
                      n=n/1000;
               else if(n%100==14)
                      n=n/100;
               else if(n%10==1)
                      n=n/10;
               else
               {
                     flag=1;
                     break;
               }
         }
         if(flag)
                printf("NO
    ");
         else
                printf("YES
    ");
         return 0;
    
    }
    

      

  • 相关阅读:
    TCP首部
    IP
    ARP
    QYT教主TCPIP2017 TCP部分 视频笔记
    卷一第二十二章:UDP原理
    卷一第二十一章:TCP原理
    卷一第二十章:IPV6基础
    卷一十九章:DHCP (不涉及工作,暂停)
    目录
    Educational Codeforces Round 90 (Rated for Div. 2)
  • 原文地址:https://www.cnblogs.com/a972290869/p/4240105.html
Copyright © 2011-2022 走看看