我是萌新刚学OI

P2152 [SDOI2009] SuperGCD

代码放在二楼是个好习惯 ``` wcsl( type arr=array[0..10100] of longint; var s1,s2:ansistring; l1,l2,i,j,t:longint; ans,ans1,ta,tb,p:arr; procedure print(x:arr); begin for i:=x[0] downto 1 do write(x[i]); writeln; end; function cheng(x,y:arr):arr; var t:longint; begin fillchar(ans,sizeof(ans),0); for i:=1 to x[0] do for j:=1 to y[0] do begin t:=i+j-1; ans[t]:=ans[t]+x[i]*y[j]; ans[t+1]:=ans[t+1]+ans[t] div 10; ans[t]:=ans[t] mod 10; end; if ans[x[0]+y[0]]>0 then ans[0]:=x[0]+y[0] else ans[0]:=x[0]+y[0]-1; exit(ans); end; function jian(x,y:arr):arr; begin fillchar(ans,sizeof(ans),0); for i:=1 to x[0] do begin ans[i]:=ans[i]+x[i]-y[i]; if ans[i]<0 then begin ans[i]:=ans[i]+10; dec(ans[i+1]); end; end; if ans[x[0]]=0 then ans[0]:=x[0]-1 else ans[0]:=x[0]; exit(ans); end; function _power:arr; var x,ans:arr; begin fillchar(x,sizeof(x),0); fillchar(ans,sizeof(ans),0); x[1]:=2; ans[1]:=1; x[0]:=1; ans[0]:=1; for i:=1 to t do ans:=cheng(ans,x); exit(ans); end; function div2(x:arr):arr; begin fillchar(ans,sizeof(ans),0); for i:=x[0] downto 1 do begin ans[i]:=x[i+1]*5+x[i] div 2; x[i]:=x[i] mod 2; end; if ans[x[0]]=0 then ans[0]:=x[0]-1 else ans[0]:=x[0]; exit(ans); end; function same(x,y:arr):boolean; begin if x[0]<>y[0] then exit(false); for i:=x[0] downto 1 do if x[i]<>y[i] then exit(false); exit(true); end; function small(x,y:arr):boolean; begin if x[0]>y[0] then exit(false); if x[0]<y[0] then exit(true); for i:=x[0] downto 1 do if x[i]<y[i] then exit(true) else if x[i]>y[i] then exit(false); exit(false); end; function gcd(a,b:arr; c:longint):arr; var t1,t2:longint; begin if same(a,b) then begin t:=c; exit(a); end; if small(a,b) then exit(gcd(b,a,c)); t1:=0; t2:=0; while (a[1] mod 2=0) and (b[1] mod 2=0) do begin a:=div2(a); b:=div2(b); inc(c); end; if a[1] mod 2=0 then begin a:=div2(a); t1:=1; end; if b[1] mod 2=0 then begin b:=div2(b); t2:=1; end; if (t1=0) and (t2=0) then a:=jian(a,b); exit(gcd(a,b,c)); end; begin readln(s1); l1:=length(s1); readln(s2); l2:=length(s2); fillchar(ta,sizeof(ta),0); fillchar(tb,sizeof(tb),0); for i:=1 to l1 do ta[i]:=ord(s1[l1-i+1])-48; for i:=1 to l2 do tb[i]:=ord(s2[l2-i+1])-48; ta[0]:=l1; tb[0]:=l2; ans1:=gcd(ta,tb,0); if t<>0 then begin p:=_power; ans1:=cheng(ans1,p); //power(2,t); end; print(ans1); end. ```
by Celestial_Scarlet @ 2019-02-12 19:30:03


大佬666
by 公主殿下MIKU @ 2019-02-12 19:30:35


orz
by 公主殿下MIKU @ 2019-02-12 19:30:44


@[公主殿下MIKU](/space/show?uid=113773) 红名大佬太fAKe了QAQ
by Celestial_Scarlet @ 2019-02-12 19:33:19


@[baoyu](/space/show?uid=93465) 要不是我学C++我早帮您了……
by UKE自动稽 @ 2019-02-12 19:35:04


萌新都是怪物系列
by Jameswood @ 2019-02-12 19:35:11


@[_UKE自动机_](/space/show?uid=71371) 要不是我学Pascal我早~~抄~~看题解去了……
by Celestial_Scarlet @ 2019-02-12 19:35:39


~~我今天就是MLE1次,MLE10次,也不会用python!~~
by Celestial_Scarlet @ 2019-02-12 19:36:38


刚学OI就做提高+的题啊! 666
by xsI666 @ 2019-02-12 19:38:53


深感C艹的伟大
by Rbu_nas @ 2019-02-12 19:40:41


| 下一页