HDOJ2099_整数的尾数

一道我觉得不会这么简单,而后暴力盲打居然给过了的题。php

HDOJ2099_整数的尾数code

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>

int main()
{
    int a,b,n;
    int i,j;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        int n2[100];
        int cnt=0;
        if(a==0&&b==0)
        {
            break;
        }
        for(i=0;i<=99;i++)
        {
            if((a*100+i)%b==0)
            {
                n2[cnt++]=i;
            }
        }
        for(i=0;i<cnt;i++)
        {
            printf("%02d",n2[i]);
            i==cnt-1?printf("\n"):printf(" ");
        }
    }
    return 0;
}

思路

很简单,就是对最后的两位数进行0~99的遍历一遍,找出全部的可能就OK了。blog

相关文章
相关标签/搜索