#27682: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
c184. 盈虧互補 -- 板橋高中教學題 | From: [27.105.52.161] | 發表日期 : 2021-10-23 13:41

#include <iostream>
using namespace std;

int main(){
int n, s;
while (cin >> n){
if (n==0) break;
s=0;
for (int i=1; i<n; i++){
if (n%i==0){
s+=i;
}
}
if (s==n){
cout <<"="<< n <<endl;
continue;
}
int s2=0;
for (int i=1; i<s; i++){
if (s%i==0){
s2+=i;
}
}
if (s2==n){
cout << s <<endl;
}
else {
cout << 0 <<endl;
}
}
}
 
ZeroJudge Forum