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