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

方法没错,这样也超时o(n),没道理

Posted by wangguanjin at 2005-09-14 11:03:03 on Problem 1775
#include <stdio.h>

int main()
{
	int i,q,r,n;
	bool yes;
  while(true)
  {
	yes = true;
	scanf("%d",&n);
	if(n<0) break;
	q = n;
	for(i=2;i<=n-1;i++)
	{
		r = q%i;// printf("%d\n",r);
		if(r!=1 && r!=0) 
		{
			yes =false; break;
		}
		
		q = q / i;
	}
	if(yes && (q==1||q==0))
		printf("YES\n");
	else
		printf("NO\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