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

Re:为什么把AC的C++翻译过来就WA了???

Posted by 568082880 at 2015-05-14 08:29:38 on Problem 3641
In Reply To:为什么把AC的C++翻译过来就WA了??? Posted by:568082880 at 2015-05-14 08:29:25
var a,p:int64;
function prime(n:int64):boolean;
var j:int64;
begin
 if n=2 then
  exit(true);
 if (n<=1)or(n mod 2=0) then
  exit(false);
 j:=3;
 while(j<=trunc(sqrt(n))) do
  begin
   if n mod j=0 then
    exit(false);
   j:=j+2;
  end;
 exit(true);
end;
function pd(a,b,c:int64):int64;
var d,t:longint;
begin
 d:=1;
 t:=a;
 while b>0 do
  begin
   if b mod 2=1 then
    d:=(d*t) mod c;
   b:=b shr 1;
   t:=t*t mod c;
  end;
 exit(d);
end;
begin
 readln(p,a);
 while (p<>0)and(a<>0) do
  begin
   if prime(p) then
    writeln('no')
   else
    if pd(a,p,p)=a then
     writeln('yes')
    else
     writeln('no');
   readln(p,a);
  end;
end.

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