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

我是用 Euler PHI 函数做的,程序相当简单,但是错了,急求高手!

Posted by gardner at 2005-10-15 22:14:10 on Problem 2407
#include <stdio.h>
void main()
{
	long input,i,save;
	scanf("%ld",&input);
	while(input!=0){
		if(input==1)printf("0\n");
		else {
			save=input;
			if(input%2==0)save/=2;
			while(input%2==0)input/=2;
			for(i=3;input!=1;i=i+2){
				if(input%i==0)save=save*(i-1)/i;
				while(input%i==0)input/=i;
			}
			printf("%ld\n",save);
		}
		scanf("%ld",&input);
	}
}

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