View Code of Problem 93

#include<bits/stdc++.h>
using namespace std;

int main() {
    int m,n,p=0;
    int a[6000],b[6000];
    cin>>m>>n;

    for (int i = m; i < n; ++i) {
        int s1=0,s2=0;
        for (int j = 1; j <i; ++j) {
            if (i % j == 0)
                s1 += j;
        }
            for (int t = i+1; t < n; ++t) {
                s2=0;
                for (int k = 1; k <t; ++k) {
                    if (t % k == 0)
                        s2 += k;
                    if(s2>s1) break;
                }
                if((s1==t)&&(i==s2)){
                    a[p]=i;b[p]=t;
                   p++;
                }
            }
    }
for(int i=0;i<p;i++)
{
    cout<<a[i]<<" "<<b[i]<<endl;
}
return 0;
}

Double click to view unformatted code.


Back to problem 93