目录

problems
名称好朋友
题目编号P1851
题目链接luogu.com.cn/…
来源Luogu
算法分类数论, 数学
难易程度入门

好朋友

想法

直接暴力枚举

代码实现

#include<cstdio>
 
int count(int x) {
    int sum = 0;
    for(int i=1; i<x; i++)
        if(x % i == 0)
            sum += i;
    return sum;
}
 
int main() {
    int s;
    scanf("%d", &s);
    while(true) {
        int other = count(s);
        if(other != s && count(other) == s ) {
            printf("%d %d", s, other);
            break;
        }
        s++;
    }
    return 0;
}