bzoj 1192: [HNOI2006]鬼谷子的钱袋

 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.

按二进制分解

你可能感兴趣的:(bzoj 1192: [HNOI2006]鬼谷子的钱袋)