问题来源

HDU-2099

问题描述

一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢?

输入

输入数据有若干组,每组数据包含二个整数a,b(0<a<10000, 10<b<100),若遇到0 0则处理结束。

输出

对应每组数据,将满足条件的所有尾数在一行内输出,格式见样本输出。同组数据的输出,其每个尾数之间空一格,行末没有空格。

例子

2周题-HDU-2099--整除的尾数

AC的代码

#include <iostream>
#include<vector>
using namespace std;

int main()
{
	int i,t;
	while (cin >> i >> t)
	{
		vector<int>s;
		if (i == 0)
			break; 
			i= i * 100;
		for (int j = 0; j < 100; j++)
		{
			
			if (((j+i) % t) == 0)
				s.push_back(j);
		}
		for (int g = 0; g < s.size(); g++)
		{
			if (s[g] < 10)
				cout << "0" << s[g];
			else
				cout << s[g];
			if (g != (s.size() - 1))
				cout <<" ";
			else
				cout << endl;
		}



	}
}

解题思路

a*100+j(0<=j<99)/b满足题意,vector保存满足题意的j,输出(小于10的要加0,最后一个数后不加空格加换行)。

相关文章:

  • 2021-09-17
  • 2022-01-18
  • 2021-12-19
  • 2021-07-29
  • 2022-02-17
  • 2021-07-13
  • 2022-01-30
  • 2021-11-23
猜你喜欢
  • 2022-02-27
  • 2021-09-26
  • 2021-06-06
  • 2021-06-30
  • 2021-05-26
  • 2021-08-30
相关资源
相似解决方案