Sunday, June 7, 2015

UVa 382 - Perfection

// UVa 382 - Perfection

#include <iostream>
#include <stdio.h>
using namespace std;

#define datatype unsigned long long int

int main() {
	datatype n;
	cin >> n;
	cout << "PERFECTION OUTPUT" << endl;
	while (n) {
		printf("%5llu  ", n);
		datatype s = 0;
		for (datatype i = 1; i < n; i++) {
			if (n % i == 0)
				s += i;
		}
		if (s == n)
			cout << "PERFECT" << endl;
		else if (s < n)
			cout << "DEFICIENT" << endl;
		else
			cout << "ABUNDANT" << endl;

		cin >> n;
	}
	cout << "END OF OUTPUT" << endl;
	return 0;
}

No comments:

Post a Comment