ricky_5 2008-11-04 18:07:00
点我顶贴
收藏
删除
状态: Unaccepted
测评机: Xeost[5]
得分: 90分
提交日期: 2008-11-5 10:04:00
有效耗时: 626毫秒
测试结果1: 通过本测试点|有效耗时172:ms
测试结果2: 通过本测试点|有效耗时63:ms
测试结果3: 通过本测试点|有效耗时47:ms
测试结果4: 通过本测试点|有效耗时63:ms
测试结果5: 通过本测试点|有效耗时62:ms
测试结果6: 通过本测试点|有效耗时31:ms
测试结果7: 通过本测试点|有效耗时63:ms
测试结果8: 测试结果错误.错误结果为:7357
正确结果应为:41256
测试结果9: 通过本测试点|有效耗时62:ms
测试结果10: 通过本测试点|有效耗时63:ms
提交代码:
var w,n,m,k,i,s:longint;
c2:array[1..100] of longint;
begin
readln(n,k); m:=n-1; i:=0;
while m<>0 do begin
i:=i+1; c2[i]:=m mod 2;
m:=m div 2;
end;
w:=i; s:=3;
for i:=w-1 downto 1 do begin
s:=(s*s) mod (2*k);
if c2[i]=1 then s:=(s*3) mod (2*k);
end;
s:=((s+1) div 2) mod k;
if n=1 then s:=1;
writeln(s);
end.
Powered By RenQing | Art Design By Azuis