2005年第11届信息学奥林匹克pascal普及组试题求助

来源:百度知道 编辑:UC知道 时间:2024/06/04 06:28:20
循环(circle.pas):
例:2^1=2; 2^2=4; 2^3=8; 2^4=16; 2^5=32;
所以2的末1位的整次幂循环次数是4次 (2,4,8,6);
输入一个正整数N(1<=N<=10^100),输入一个正整数K(1<=K<=100),求N的末K位的整次幂循环次数;
清华出的题目是很难,我只有这道题做不出,别的都做出了

program circle;
const
max_k = 100;
type
TLarge = array[0..max_k-1] of integer;
var
k,i:integer;
n_str:string;
n,t,p,p_new,r,r_new:TLarge;
s:set of 0..9;

function set_large(var a:TLarge; s:string):boolean;
var
i,count:integer;
first:boolean;
begin
result := false;
count := 0;
first := true;
for i := length(s) downto 1 do
if ((not first) or (s[i] <> ' ')) then
begin
first := false;
a[count] := ord(s[i]) - ord('0');
if (a[count] < 0) or (a[count] > 9) then
exit;
inc(count);
if (count = k) then
break;
end;
for count := count to k-1 do
a[count] := 0;
result := true;
end;

procedure print_large(var a:TLarge);
var
first:boolean;
i:integer;
begin
first := true;
f