| ||||||||||
| 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 | |||||||||
Re:为什么把AC的C++翻译过来就WA了???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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator