80分(题解里过来)

var

a:array[0..20]of boolean;

i,k,n,t:integer;

procedure print(n:integer);

begin

case n of

0:write('0');

1:write('2(0)');

2:write('2');

3:write('2+2(0)');

4:write('2(2)');

5:write('2(2)+2(0)');

6:write('2(2)+2');

7:write('2(2)+2+2(0)');

8:write('2(2+2(0))');

9:write('2(2+2(0))+2(0)');

10:write('2(2+2(0))+2');

11:write('2(2+2(0))+2+2(0)');

12:write('2(2+2(0))+2(2)');

13:write('2(2+2(0))+2(2)+2(0)');

14:write('2(2+2(0))+2(2)+2');

end;

end;

begin

readln(n);

k:=-1; t:=-1;

fillchar(a,sizeof(a),false);

while n>0 do

begin

inc(k);

if odd(n) then a[k]:=true;

if (t=-1)and(odd(n)) then t:=k;

n:=n div 2;

end;

for i:= k downto t do

if a[i] then

begin

write('2('); print(i); write(')');

if it then write('+');

end;

end.

一组错误,一组长了

2 条评论

  • @ 2009-10-31 10:56:40

    谢谢

    可我在看之前已经AC了,呵呵……

  • @ 2009-10-29 21:01:09

    因为当写2^1的时候应该写2,但是你那样的话会写2(2(0))

  • 1

信息

ID
1597
难度
3
分类
模拟 点击显示
标签
递交数
2826
已通过
1422
通过率
50%
被复制
10
上传者