Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
確實很噁心,1的問題,還有POJ用的哪年的破编译器,連sqrt(n)都過不了,還非得sqrt(n+0.0),白贡献了一次CE#include <iostream> #include <stdio.h> #include <cmath> using namespace std; void print(int n){ if(n<10) printf(" "); else if(n<100) printf(" "); else if(n<1000) printf(" "); else if(n<10000) printf(" "); printf("%d",n); printf(" "); } char d[3][23] = {"DEFICIENT", "PERFECT", "ABUNDANT"}; int main() { printf("PERFECTION OUTPUT\n"); int n; while(1){ scanf("%d",&n); if(!n)break; int r = 1; int s = (int)sqrt(n+0.0); if(s*s==n){ r+=s; s--; } for(int i = 2; i <= s; i++){ if(!(n%i)){ r += (i + n/i); } } int q; if((r-n)>>31) q=0; else if(!(r^n)) q=1; else q=2; if(!(n^1)) q=0; print(n); printf("%s\n",d[q]); } printf("END OF OUTPUT\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator