#include <iostream>
using namespace std;
int main()
{
int x, L, M;
cin >> x;
L = 0;
M = 0;
while (x > 0){
M = M + 1;
if(x % 2 != 0){
L = L + 1;
}
x = x / 2;
}
cout << L << endl << M << endl;
return 0;
}
|
x = int(input())
L = 0
M = 0
while x > 0:
M = M + 1
if x % 2 != 0:
L = L + 1
x = x // 2
print(L)
print(M)
|
алг
нач
цел x, L, M
ввод x
L := 0
M := 0
нц пока x > 0
M := M + 1
если mod(x, 2) <> 0
то
L := L + 1
все
x := div(x, 2)
кц
вывод L, нс, M
кон
|
var x, L, M: integer;
begin
readln(x);
L := 0;
M := 0;
while x > 0 do
begin
M := M + 1;
if x mod 2 <> 0 then
L := L + 1;
x := x div 2;
end;
writeln(L);
writeln(M);
end.
|