整除的尾數(shù)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 52300 Accepted Submission(s): 22120
Problem Description
一個整數(shù),只知道前幾位,不知道末二位,被另一個整數(shù)除盡了,那么該數(shù)的末二位該是什么呢?
Input
輸入數(shù)據(jù)有若干組,每組數(shù)據(jù)包含二個整數(shù)a,b(0<a<10000, 10<b<100),若遇到0 0則處理結束。
Output
對應每組數(shù)據(jù),將滿足條件的所有尾數(shù)在一行內(nèi)輸出,格式見樣本輸出。同組數(shù)據(jù)的輸出,其每個尾數(shù)之間空一格,行末沒有空格。
Sample Input
200 40
1992 95
0 0
Sample Output
00 40 80
15
#include<iostream>
using namespace std;
void main() {
int n, m;
while (cin >> n >> m&&m!=0&&n!=0) {
int flag = 0;
for (int i = 0; i < 100; i++) {
if ((n * 100 + i) % m == 0) {
if (i < 10) {
if (flag == 1)cout << ' ';
cout << "0" << i;
flag = 1;
}
if (i >= 10) {
if (flag == 1)cout << ' ';
flag = 1;
cout << i;
}
}
}
cout << endl;
}
}