UVA 1734: Numbered Card ( ACM-ICPC Dhaka Regional 2015 ) Idea: The problem is asking for total numbers of subsets that can be constructed by using only numbers within 1 to N such that no two numbers contains same digit on their representation . Where, N can be as much as 1e9. So, main generalization to this problem is considering the pattern of numbers that can be included in a subset.Let us assume that 1,11,111,111,1111 are same type of numbers. Similarly, 2,22,222,2222...also 12,21,211,122,121 are of same type of numbers. So, it is easy to see that there are total 2^10 type of numbers.So, total size of subset will never be great than 2^10. So, if we calculate for each type of numbers how many are there within 1 to N. (This can be done with digit dp) Then, we may proceeds for core idea of problem. The idea is that, we can find total different subsets by DP keeping track of current position out of total 2^10 position and the mask of different digit included...
Comments
Post a Comment