p1472 求助

郁闷啊,好不容易过了第5个测试点,6 7 8过不了啊

拜托各大牛看下

编译通过...

├ 测试数据 01:答案正确... 0ms

├ 测试数据 02:答案正确... 0ms

├ 测试数据 03:答案正确... 0ms

├ 测试数据 04:答案正确... 0ms

├ 测试数据 05:答案正确... 494ms

├ 测试数据 06:答案错误... ├ 标准行输出

 ├ 错误行输出

├ 测试数据 07:答案错误... ├ 标准行输出

 ├ 错误行输出

├ 测试数据 08:答案错误... ├ 标准行输出

 ├ 错误行输出

├ 测试数据 09:答案正确... 0ms

├ 测试数据 10:答案正确... 0ms

---|---|---|---|---|---|---|---|-

const

e=100000000;

type

arr=array[0..2000]of longint;

var

c,sum,zhong,b,san:arr;

n,k,i,sss,ss,o:longint;

s:ansistring;

ch:char;

function max(x,y:longint):longint;

begin

if x>y then exit(x)else exit(y);

end;

//---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|--

procedure jiafa(var x,y:arr);

var i,q:longint;

begin

x[0]:=max(x[0],y[0]);

q:=0;

for i:=1 to x[0] do

begin

x[i]:=x[i]+y[i]+q;

q:=x[i] div e;

x[i]:=x[i]mod e;

end;

if q>0 then begin

inc(x[0]);x[x[0]]:=q;

end;

end;

//---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|-

procedure jianfa(var x,y:arr);

var i,q:longint;

begin

for i:=1 to x[0] do

begin

if x[i]sum[0] then exit(false);

if c[0]sum[i] then exit(false);

if c[i]0 then begin inc(s[0]); s[s[0]]:=x; end

end;

//---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

begin

read(n);read(ch);

read(s);

ss:=length(s);

i:=1;

while s[i]='0' do

begin

inc(i);

end;

dec(i);

delete(s,1,i);

ss:=length(s);

if ss mod 8=0 then

begin

c[0]:=ss div 8;

for i:=1 to c[0] do

val(copy(s,ss-i*8+1,8),c[i]);

end

else

begin

c[0]:=ss div 8+1;

for i:=1 to c[0]-1 do

val(copy(s,ss-i*8+1,8),c[i]);

sss:=ss-(c[0]-1)*8;

val(copy(s,1,sss),c[c[0]]);

end;

//---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|--

if (n=1)and(c[1]>1) then begin write('-1'); exit; end;

if (n=2)then begin

if c[1]=1 then begin write('1'); exit; end

else if c[1]=2 then begin write('2'); exit; end

else if c[1]=3 then begin write('3'); exit; end

else begin write('-1');exit; end;

end;

if (n>=c[1])and(c[0]=1) then begin write(c[1]); exit; end;

//---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

san[1]:=3;

san[0]:=1;

sum[1]:=n;

sum[0]:=1;

zhong[1]:=n;

zhong[0]:=1;

o:=1;

while not(panduan) do

begin

for i:=0 to sum[0] do

b[i]:=sum[i];

p2(zhong);

jianfa(zhong,san);

jiafa(sum,zhong);

inc(o);

end;

san[1]:=2;

jianfa(c,b);

zhong[1]:=1;

zhong[0]:=1;

for i:=1 to o do

p2(zhong);

jiafa(zhong,c);

jianfa(zhong,san);

write(zhong[zhong[0]]);

for i:=zhong[0]-1 downto 1 do

if zhong[i]>10000000 then write(zhong[i])

else if zhong[i]>1000000 then write('0',zhong[i])

else if zhong[i]>100000 then write('00',zhong[i])

else if zhong[i]>10000 then write('000',zhong[i])

else if zhong[i]>1000 then write('0000',zhong[i])

else if zhong[i]>100 then write('00000',zhong[i])

else if zhong[i]>10 then write('000000',zhong[i])

else write('0000000',zhong[i]);

end.

0 条评论

目前还没有评论...

信息

ID
1472
难度
8
分类
其他 | 二分查找高精度 点击显示
标签
递交数
1351
已通过
175
通过率
13%
被复制
5
上传者