View Code of Problem 93

#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <math.h>
using namespace std;

int yinzihe(int x) {
    int sum = 0;
    for(int i=1; i<x; i++ ){
        if(x % i == 0){
            sum += i;
        }
    }
    return sum;
}

int main() {
    int m,n;
    cin >> m >> n;
    for(int i=m; i<=n; i++){
        int z = yinzihe(i);
        if(i<z && z<=n && yinzihe(z) == i){
            cout << i << " "<< z << endl;
        }
    }
    return  0;
}

Double click to view unformatted code.


Back to problem 93