讨论 / AC pascal 如有简短代码,联系qq邮箱 qq邮箱:2637453212@qq.com
g++ 2016-03-24 18:38:09
点我顶贴 收藏 删除
type use=array[1..1000] of integer;

var n:string;

meen,realk:integer;

num1,ans,need:use;

procedure init;

var inite,k:string;

space,error,for1:integer;

begin

readln(inite);

space:=pos(' ',inite);

n:=copy(inite,1,space-1);

k:=inite; delete(k,1,space);

val(k,realk,error);

if length(n)>=for1 then delete(n,1,length(n)-realk);

for for1:=realk downto 1 do if length(n)>=for1 then

num1[realk-for1+1]:=ord(n[for1])-48 else num1[realk-for1+1]:=0;

end;

procedure mult(var a:use;b:use;k1,k2:integer);

var for1,for2,x,y,m:integer;

c:array[1..100] of integer;

begin

fillchar(c,Sizeof(c),0);

if k1>k2 then m:=k1 else m:=k2;

for for1:=1 to k1 do

for for2:=1 to k2 do begin

x:=a[for1]*b[for2];

y:=c[for1+for2-1];

if for1+for2-1<=m then c[for1+for2-1]:=(x+y) mod 10;

if for1+for2<=m then c[for1+for2]:=c[for1+for2]+(x+y) div 10;

end;

for for1:=1 to m do a[for1]:=c[for1];

end;

procedure TheWrongWay;

begin

writeln(-1);

readln;

halt;

end;

procedure working;

var for1,for2,for3,box,new:integer;

num2,num3,rp:use;

find:array[0..9] of boolean;

Yes:boolean;

begin

fillchar(need,Sizeof(need),0);

for for1:=1 to realk do begin

if for1=1 then begin

ans[1]:=1;

new:=1;

fillchar(num3,Sizeof(num3),0);

for for2:=1 to realk do num3[for2]:=num1[for2];

end;

fillchar(num2,Sizeof(num2),0);

for for2:=1 to realk do num2[for2]:=num3[for2];

if for1>1 then for for2:=1 to (need[for1-1])-1 do mult(num3,num2,realk,realk);

for for2:=1 to for1 do num2[for2]:=num1[for2];

new:=0; fillchar(find,Sizeof(find),false);

box:=num2[for1];find[box]:=true;Yes:=false;

repeat

inc(new);

mult(num2,num3,for1,for1);

if not find[num2[for1]] then find[num2[for1]]:=true else begin

if num2[for1]<>box then TheWrongWay else Yes:=true;

end;

until Yes;

need[for1]:=new;

fillchar(rp,Sizeof(rp),0);

if new=10 then begin

rp[2]:=1;

rp[1]:=0;

end else rp[1]:=new;

mult(ans,rp,100,2);

end;

end;

procedure print;

var for1,for2:integer;

begin

for1:=100;

while ans[for1]=0 do dec(for1);

for for2:=for1 downto 1 do write(ans[for2]);

writeln;

readln;

end;

begin

init;

working;

print;

end.

#1 1942938446@2018-12-23 13:01:47
回复 删除
天(du)才(liu)啊

这题太牛(e)X(xin)了

我说的是题,不是代码

查看更多回复
提交回复