Problem LinkLoop Through
Problem StatementTabitha loved vintage items and she was extremely fond of collecting postcards.
She came across a vintage store which would deliver an extremely unique postcard to her everyday if she wrote articles about the store for their blog.
She readily agreed to it and was very excited to collect all those postcards in her memo box
Initially, the box is empty. Each morning, Tabitha receives one new postcard for her memo box on writing that day’s article and the total number of postcards double by the end of the day. If she wants to receive x postcards at the end, how many articles should she write?
ApproachWrite down x into its binary form. If the ith least significant bit is 1 and x contains n bits, we put one postcard into this box in the morning of (n + 1 - i)thday. Then at the noon of the nth day, the box will contain x postcards. So the answer is the number of ones in the binary form of x.
using namespace std;
long long int n,i,x=0;