1 program kkul;
 2 var a:array[0..32]of longint;
 3     n,i,j,k,m:longint;
 4     kg:boolean;
 5 begin
 6   read(n);
 7   while n>0 do
 8     begin
 9       inc(m);
10       a[m]:=n div 2;
11       if n mod 2<>0
12         then inc(a[m]);
13       n:=n-a[m];
14     end;
15   writeln(m);
16 end.

按二进制分解

posted on 2016-03-03 22:58  xiyuedong  阅读(125)  评论(0编辑  收藏  举报