HDU 2099整除の末尾数解題の考え方
2805 ワード
端数
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27774 Accepted Submission(s): 11767
Problem Description
一つの整数は、前の数だけを知っていて、末の2位を知らないで、別の整数に除かれて、それではこの数の末の2位は何ですか?
Input
入力データにはいくつかのグループがあり、各グループのデータは2つの整数a,b(0
Output
各グループのデータに対応して、条件を満たすすべての末尾数を1行以内に出力し、フォーマットはサンプル出力を参照してください.同じグループのデータの出力で、各末尾の間に1つのグリッドが空で、行末にスペースがありません.
Sample Input
200 40 1992 95 0 0
Sample Output
00 40 80 15
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27774 Accepted Submission(s): 11767
Problem Description
一つの整数は、前の数だけを知っていて、末の2位を知らないで、別の整数に除かれて、それではこの数の末の2位は何ですか?
Input
入力データにはいくつかのグループがあり、各グループのデータは2つの整数a,b(0
Output
各グループのデータに対応して、条件を満たすすべての末尾数を1行以内に出力し、フォーマットはサンプル出力を参照してください.同じグループのデータの出力で、各末尾の間に1つのグリッドが空で、行末にスペースがありません.
Sample Input
200 40 1992 95 0 0
Sample Output
00 40 80 15
#include<stdio.h>
void main()
{
int a,b,t,count;
scanf("%d %d",&a,&b);
while(a != 0)
{
//printf("a = %d,b = %d
",a,b);
t = 0;
count = 0;
while(t <= 99)
{
if((a*100 + t)%b == 0)
{
count ++;
if(t < 10 && count > 1)
printf(" 0%d",t);
else if(t < 10 && count == 1)
printf("0%d",t);
else if(t >= 10 &&count > 1)
printf(" %d",t);
else if(t >= 10 && count == 1)
printf("%d",t);
}
if(count)
t += b;
else
t++;
//printf("count = %d
",count);
}
printf("
");
scanf("%d %d",&a,&b);
}
}