杭电acm2099

http://acm.hdu.edu.cn/showproblem.php?pid=2099

先乘以100求得余数,用整除的那个数依次叠加,减去余数,所以结果小于100的都是答案;输出时用printf(“%02d”,ans);可以保证宽度,在不够位时自动补0

View Code
 1 #include<stdio.h>
 2 int main()
 3 {
 4  int a,b,i,ans,s[100],j;
 5  while(scanf("%d%d",&a,&b)&&(a||b))
 6     {
 7      a*=100;
 8      ans=a%b;
 9      i=0;
10      if(ans==0)
11        s[i++]=ans;//如果是0,直接存到数组中
12      a=b;
13      while(b-ans<100)
14        {
15         s[i++]=b-ans;
16         b+=a;
17        }//依次叠加并存储
18      for(j=0;j<i;j++)
19        if(j==i-1)
20          printf("%02d\n",s[j]);
21        else printf("%02d ",s[j]);//按格式输出
22     }
23  return 0;
24 }
原文地址:https://www.cnblogs.com/huzhenbo113/p/2988725.html