AmberFrame's blog

By AmberFrame, history, 7 years ago, In English

including practice

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it

By AmberFrame, 8 years ago, In English

Here's another method. Let's assume the maximum digit of number x is p.For example, the maximum digit of 260d7 is d(13).

If the binary form of number x contains 2^p ,then x will get a decrease after those steps.Otherwise,it not.

Now you see that only p matters the result.We can enumerate the p and form a dp[i][0/1][0/1], which means IN THE FIRST i DIGITS,whether x<L or x=L and whether the p has appeared in x.We can enumerate the next digit to transfer it.If the current digit we enumerate contains 2^p,we just simply discuss about it.

Time Complexity:O(T*16*16*2*2*16)

Code:24938218

Full text and comments »

  • Vote: I like it
  • +19
  • Vote: I do not like it