Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 51968 Accepted Submission(s): 22013
Problem Description 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢?
Input 输入数据有若干组,每组数据包含二个整数a,b(0<a<10000, 10<b<100),若遇到0 0则处理结束。
Output 对应每组数据,将满足条件的所有尾数在一行内输出,格式见样本输出。同组数据的输出,其每个尾数之间空一格,行末没有空格。
Sample Input
200 40
1992 95
0 0
Sample Output
00 40 80
15
题目分析:
运算上不难,关键是格式,博主也是submit了好多次,最后才ac了。
程序分析:
调用头文件,使用vector类存储数量不定的子数字,用size()返回有效元素的个数s,用for循环输出s-1个元素,并输出空格,最后一个元素单独输出,后面不带空格。
程序实现:
#include <iostream>
#include<vector>
using namespace std;
int main()
{
int a,b,c,d,i=0;
while (cin >> a >> b)
{
if (a == 0 && b == 0)
{
break;
}
vector <int> s;
a = a * 100;
for (c = 0; c < 100; c++)
{
if ((a + c) % b == 0)
s.push_back(c);
}
d = s.size();
for ( i = 0; i < d - 1; i++)
{
if (s[i] < 10)
cout << "0" << s[i] << " ";
else
cout << s[i] << " ";
}
if (s[i] < 10)
cout << "0" << s[i] ;
else
cout << s[i] ;
cout << endl;
}
}