POJ C Programming Advanced Programming Question # #: Contains K 3 of the number

Source: Internet
Author: User

Programming Question #: Contains K 3 of the number

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Describe

Enter two positive integers m and K, where 1 < m < 100000,1 < K <5, determine if M can be divisible by 19, and exactly contain K 3, if the condition is met, output yes, otherwise, output No.

For example, enter:

43833 3

Satisfy condition, output yes

If you enter

39331 3

Although there are 3 3, but not divisible by 19, and do not meet the conditions, should output no

Input

Value of M and K, space interval

Output

Output YES When conditions are met, output no when not satisfied

Sample input
43833 3
Sample output
YES
1#include <iostream>2 using namespacestd;3 4 intMain () {5     intM, K, count=0;6CIN >> M >>K;7         BOOLright1 =false, right2 =false;8         if(M% +==0) {9right1 =true;Ten         } One          while(M >0) { A             if(M%Ten==3) { -count++; -             } theM/=Ten; -         } -         if(Count = =k) { -Right2 =true; +         } -         if(Right1 &&right2) { +cout <<"YES"; A}Else { atcout <<"NO"; -         } -         return 0; -}

POJ C Programming Advanced Programming Question # #: Contains K 3 of the number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.