Law of Commutation

TimeLimit:1000MS  MemoryLimit:32768KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
As we all know, operation ''+'' complies with the commutative law. That is, if we arbitrarily select two integers $a$ and $b$, $a + b$ always equals to $b + a$. However, as for exponentiation, such law may be wrong. In this problem, let us consider a modular exponentiation. Give an integer $m = 2^n$ and an integer $a$, count the number of integers $b$ in the range of $[1,m]$ which satisfy the equation $a^b \equiv b^a$ (mod $m$).
Input
There are no more than $2500$ test cases.

Each test case contains two positive integers $n$ and a seperated by one space in a line.

For all test cases, you can assume that $n \leq 30, 1 \leq a \leq 10^9$.
Output
For each test case, output an integer denoting the number of $b$.
SampleInput
2 3
2 2
SampleOutput
1
2
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量2
AC率50.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: