好朋友

来源:互联网 发布:商友软件 编辑:程序博客网 时间:2024/05/16 00:49

传送门
一个比较水的题
根据定义暴力枚举即可AC

#include <cstdio>#include <iostream>#include <map>#include <cmath>using namespace std;int cf(int x){    int tot=0;    for(int i=1;i<=sqrt((double)(x+0.5));i++)    if(x%i==0)     {        tot+=i;        if(i*i!=x) tot+=x/i;      }    return tot-x;}int main(){    int s;    scanf("%d",&s);    for(int i=s;;i++)     {        int d1=cf(i);        if(d1==i) continue;        int d2=cf(d1);        if(d2==i)        {            printf("%d %d",i,d1);            return 0;        }     }}
原创粉丝点击