codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

579A.md (1188B)


      1 Source: https://codeforces.com/problemset/problem/579/A
      2 
      3 A. Raising Bacteria
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are a lover of bacteria. You want to raise some bacteria in a box.
     22 
     23 Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment.
     24 
     25 What is the minimum number of bacteria you need to put into the box across those days?
     26 
     27 Input
     28 
     29 The only line containing one integer *x* (1 ≤ *x* ≤ 109).
     30 
     31 Output
     32 
     33 The only line containing one integer: the answer.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 5
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 2
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 8
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 1
     59 ```
     60 
     61 Note
     62 
     63 For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
     64 
     65 For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1.