Determining whether an integer is divisible by 19, and contains exactly n-3

Description questions
Enter two positive integers m and k, where 1 <m <100000,1 <k <5, determines whether m is divisible by 19, and contains exactly k-3, if the condition is satisfied, the output YES, otherwise, output NO. For example, type: 438 333 satisfy the condition, output YES. If the input: 393 313 3 3 Notwithstanding, but can not be divisible by 19, it does not satisfy the condition, to be output NO.
Input Format
Multiple sets of inputs, each set of inputs:
The values ​​of m and k, intermediate spacer with a single space.
Output Format
YES output condition is satisfied, the output of NO is not satisfied.
Sample input
43833 3
Sample Output
YES
#include <stdio.h>
int main()
{
    int m,k,i,y;
    while(scanf("%d %d",&m,&k)!=EOF)
    {
        y=1; i=0;
        while(1)
        {
            if(m/y==0)
                break;
            if(m/y%10==3)
                i++;
                y*=10;
        }
        if(m%19==0&&k==i)
            printf("YES\n");
        else
            printf("NO\n");
            }
    return 0;
}
Published 32 original articles · won praise 9 · views 70000 +

Guess you like

Origin blog.csdn.net/yi__cao/article/details/78486906