#include <iostream>
#include <vector>
using namespace std;
int main (void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int m=0,n=0,u,s,q,r,p;
int i;
cin>>i;
vector<int>a;
vector<int>b;
int sum[2];
for(u=1;u<i;u++)
if(i%u==0){
a.push_back(u);
sum[0]=u+sum[0];
n++;
}
for(s=1;s<sum[0];s++)
if(sum[0]%s==0){
b.push_back(s);
sum[1]=sum[1]+s;
m++;
}
if(sum[0]==i){
n=n-1;
for(q=0;q<n;q++){
cout<<a[q]<<"+";
}
cout<<a[q];
cout<<"="<<i<<endl;
cout<<i<<" is perfect.";
}
else if(sum[1]==i)
{
n=n-1;
for(q=0;q<n;q++){
cout<<a[q]<<"+";
}
cout<<a[q];
cout<<"="<<sum[0]<<endl;
m=m-1;
for(p=0;p<m;p++)
{
cout<<b[p]<<"+";
}
cout<<b[p];
cout<<"="<<i<<endl;
cout<<i<<" and "<<sum[0]<<" are friends.";
}
else
{
n=n-1;
for(q=0;q<n;q++)
cout<<a[q]<<"+";
cout<<a[q];
cout<<"="<<sum[0]<<endl;
if(sum[1]!=0)
{
m=m-1;
for(p=0;p<m;p++)
{
cout<<b[p]<<"+";
}
cout<<b[p];}
cout<<"="<<sum[1]<<endl;
cout<<i<<" has no friends.";
}
return 0;
}
#include
#include
using namespace std;
int main (void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int m=0,n=0,u,s,q,r,p;
int i;
cin>>i;
vectora;
vectorb;
int sum[2];
for(u=1;u if(i%u==0){
a.push_back(u);
sum[0]=u+sum[0];
n++;
}
for(s=1;s if(sum[0]%s==0){
b.push_back(s);
sum[1]=sum[1]+s;
m++;
}
if(sum[0]==i){
n=n-1;
for(q=0;q
cout< }
cout< cout<<"="< cout< }
else if(sum[1]==i)
{
n=n-1;
for(q=0;q
cout< }
cout< cout<<"="< m=m-1;
for(p=0;p {
cout< }
cout< cout<<"="< cout< }
else
{
n=n-1;
for(q=0;q cout< cout< cout<<"="< if(sum[1]!=0)
{
m=m-1;
for(p=0;p {
cout< }
cout< cout<<"="< cout< }
return 0;
}
找因數只要算到平方根就好了