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 |
下面是我的代码,怎么老是runtime error,那位仁兄帮帮忙啊 ,请教高手啊,#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator