Problem 3033 --Equation

3033: Equation

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Cuber QQ has encountered a math problem during his research of "nothing related to math", he thought the problem too boring for him, and decided to leave it to you. You might be curious about more background about why this problem appeared in his research, but to save your time, let's say "the background isn't helpful for you to solve this problem". 

Given nnmm, count the number of sequence x1,x2,…,xnx1,x2,…,xn such that x21+x22+⋯+x2n−1≡x2n(modm)x12+x22+⋯+xn−12≡xn2(modm) and 0≤xi<m0≤xi<m for 1≤i≤n1≤i≤nmm is odd in this problem. 
The first line of the input is an integer tt (1≤t≤25001≤t≤2500), where tt is the number of test cases. 

Then follows tt test cases, each of which is a line with two space-separated integers nn and mm (3≤n≤100,3≤m≤999 999 9993≤n≤100,3≤m≤999 999 999 and mm is odd).
For each test case, output the answer modulo 109+7109+7.
3
3 5
5 3
9 101
25
81
980480839

推荐代码 查看3033 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 7 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛