AmberFrame's blog

By AmberFrame, 7 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

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

»
7 years ago, # |
  Vote: I like it +23 Vote: I do not like it

Auto comment: topic has been updated by AmberFrame (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it -18 Vote: I do not like it

D

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Well I think it's a great method(though may be too hard for me because of my poor English:D)