Pages

Friday, July 29, 2011

d010: 盈數、虧數和完全數


#include
using namespace std;
#include
#define ATSCHOOL_MINUTES 450 //60*7+30=450
#define OFFSCHOOL_MINUTES 1020 //60*17+0=1020

int main()
{
int num;
while(cin>>num)
{
int factors_sum=0;
for(int factor=1;factor {
if(num % factor == 0)
{
factors_sum += factor;
}
}
if(factors_sum cout<<"虧數"< else if(factors_sum>num)
cout<<"盈數"< else
cout<<"完全數"< }
return 0;
}

No comments:

Post a Comment