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

下面是我的代码,怎么老是runtime error,那位仁兄帮帮忙啊 ,请教高手啊,

Posted by ZhangJunhua at 2008-07-16 21:36:43 on Problem 3641
#include<iostream>
#include<math.h>
using namespace std;
int fun(int x)
{
	int m;
	if(x==2)
		return 1;
	else{
		if(x%2==0)
			return 0;
		else
			for(m=3;m<x/2;m+=2)
				if(x%m==0)
					return 0;
	}
	return 1;
}
int main()
{
	int k,i,j;
	int  p,a;
    cin>>p>>a;
	while(p!=0||a!=0)
	{
		int*b=new int[p+1];
		if(fun(p))
			cout<<"no"<<endl;
			else{
			b[1]=a;
			for(j=2;j<=p;j++)
			b[j]=(b[j-1]*a)%p;
		if(b[p]==b[1])
			cout<<"yes"<<endl;
		else
			cout<<"no"<<endl;
			}
			cin>>p>>a;
	}
	return 1;
}

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