

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
整数 が与えられます。整数の組 であって、 を で割った余りが に等しいものの個数を で割ったあまりを求めてください。
とは
整数 のビットごとの排他的論理和 は、以下のように定義されます。
- を二進数表記した際の () の位の数は、 を二進数表記した際の の位の数のうち一方のみが であれば 、そうでなければ である。
制約
入力
入力は以下の形式で標準入力から与えられる。
出力
条件を満たす整数の組 の個数を で割ったあまりを出力せよ。
入力例 1Copy
2 3
出力例 1Copy
3
条件を満たす組は の 通りです。
入力例 2Copy
10 100
出力例 2Copy
604
入力例 3Copy
1 1000000000000000000
出力例 3Copy
68038601
個数を で割ったあまりを計算することを忘れないでください。
Score : points
Problem Statement
Given are integers and . Find the number, modulo , of pairs of integers such that the remainder when is divided by is equal to .
What is ?
The XOR of integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if either or , but not both, has in the 's place, and otherwise.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of pairs of integers satisfying the condition, modulo .
Sample Input 1Copy
2 3
Sample Output 1Copy
3
Three pairs satisfy the condition: , , and .
Sample Input 2Copy
10 100
Sample Output 2Copy
604
Sample Input 3Copy
1 1000000000000000000
Sample Output 3Copy
68038601
Be sure to compute the number modulo .