大佬看看是哪里出了问题,结果错了
  • 板块P1851 好朋友
  • 楼主LeeleeL
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/12/29 21:17
  • 上次更新2023/10/28 13:23:27
查看原帖
大佬看看是哪里出了问题,结果错了
607536
LeeleeL楼主2021/12/29 21:17
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int yh(int x)
{
    int j,he=0;
    for(j=2;j<x;j++)
    {
        if(x%j==0)
        {
            he=he+j;
        }
    }
    return he;
}
int main()
{
    int s,a,b,i,yuea,yueb;
    cin >>s;
    for(i=s; ;i++)
    {
        yuea=yh(i);
        a=i;
        b=yuea;
        yueb=yh(b);
        if(yueb==a)
        {
            cout <<a<<" "<<b;
            break;
        }
    }
    cout <<endl;
    return 0;
}

2021/12/29 21:17
加载中...