UVa 10633

题目:给定一个数N。去掉末尾的数变成M。如今已知N-M,确定N。

分析:数论。简单题。

            设N = 10*a + b { 当中0 ≤ b ≤ 9 }。则M = a;

            N - M = N - a = 9*a + b,枚举全部的b计算出满足条件的N就可以。

说明:目标500题(⊙_⊙)。

#include <iostream>  
#include <cstdlib>  
#include <cmath>
  
using namespace std;  

int main()  
{  
	long long n,a;
    while (cin >> n && n) {
		int count = 0;
		for (int b = 9 ; b >= 0 ; -- b)
			if ((n-b)%9LL == 0LL) {
				if (count ++) cout << " ";
				cout << (n-b)/9LL*10+b+0LL;
			}
		cout << endl;
	}
    return 0;  
}


原文地址:https://www.cnblogs.com/tlnshuju/p/6761468.html