POJ 1528

从今以后,一定要记得设计测试数据了

1的结果应该是Deficient

 

3Y, 184ms

 

#include <iostream> #include <cmath> #define F(i,a,b) for (int i=a;i<=b;i++) using namespace std; int main() { int n; printf("PERFECTION OUTPUT/n"); while (cin >> n && n ) { printf("%5d ", n); if (n == 1) { printf("DEFICIENT/n"); continue; } int sum = 1, tmn = (int)sqrt((double)n); F(i,2,tmn) { if (n%i == 0) sum += i + n/i; } if (sum==n) printf("PERFECT/n"); else if (sum > n) printf("ABUNDANT/n"); else printf("DEFICIENT/n"); } printf("END OF OUTPUT/n"); return 0; }

你可能感兴趣的:(测试,BI)