View Code of Problem 93

#include<iostream>

using namespace std;

int f(int n) {
	int sum = 0;
	for (int i = 1; i < n; ++i) {
		if (n % i == 0) {
			sum += i;
		}
	}

	return sum;
}

int arr[5000];

int main() {
	int m, n;
	cin >> m >> n;
	for (int i = m; i <= n; ++i) {
		arr[i] = f(i);
	}

	for (int i = m; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (arr[i] == j && arr[j] == i) {
				cout << i << " " << j << endl;
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 93