Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

確實很噁心,1的問題,還有POJ用的哪年的破编译器,連sqrt(n)都過不了,還非得sqrt(n+0.0),白贡献了一次CE

Posted by KatrineYang at 2016-11-06 12:26:13 on Problem 1528 and last updated at 2016-11-06 12:28:56
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator