P21964 [HackerRank] Hackerrank number
提高
题目描述

A Hackerrank number is a magic number that can be used to get sudo permissions on the site. We are going to generate a hackerrank number from two integers A & B. Each number has two parts to it - the left (L) & the right side (R).

For eg: for the number 100101,

L could be 100 & R could be 101 (or)
L could be 1 and R could be 00101 and so on..

How to generate a hackerrank number?

Let x & y be integers such that,

(1 <= x <= A & 1 <= y <= B)

Generate the left part of any hackerrank number (L) by multiplying x and y (i.e) x*y

and the right part of any hackerrank number (R) by bitwise xor-ing x and y (i.e) x^y

Add leading zeros to R to make length(R) = length(B) + 1. Concatenate both L & R to form the hackerrank number.

Can you find the sum of all possible hackerrank numbers generated by this rule?

Input format

Each input contains 2 integers A and B separated by a space.

Constraints

1 <= A <= 30

1 <= B <= 10^{8}

Output format

Print the sum of all possible numbers that satisfy the above mentioned property.

Sample Input

2 4

Sample Output

14502

The left value can be one of {1 * 1, 1 * 2, 1 * 3, 1 * 4, 2 * 1, 2 * 2, 2 * 3, 2 * 4}

which is {1,2,3,4,2,4,6,8}

and the distinct values are {1, 2, 3, 4, 6, 8}

The right value can be one of {1^1,1^2,1^3,1^4,2^1,2^2,2^3,2^4}

which is {0, 3, 2, 5, 3, 0, 1, 6}
and the distinct values are {0, 1, 2, 3, 5, 6}

All the possible value are

{
100, 101, 102, 103, 105, 106,
200, 201, 202, 203, 205, 206,
300, 301, 302, 303, 305, 306,
400, 401, 402, 403, 405, 406,
600, 601, 602, 603, 605, 606,
800, 801, 802, 803, 805, 806
}

S = all the sum of the above = 14502.

Note: Any number can only be added once.

输入格式

见题面

输出格式

见题面

样例输入
2 4
样例输出
14502