F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

gcd

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1120    Accepted Submission(s): 388


Problem Description
Little White learned the greatest common divisor, so she plan to solve a problem: given x, n£¬
query ¡Ægcd(${x}^{a}-1$,${x}^{b}-1$) ($1\leq a,b\leq n$)
 

Input
The first line of input is an integer T ( $1\leq T\leq 300 $)
For each test case £¬the single line contains two integers x and n ( $1\leq x, n \leq 1000000$)
 

Output
For each testcase, output a line, the answer mod 1000000007
 

Sample Input
5 3 1 4 2 8 7 10 5 10 8
 

Sample Output
2 24 2398375 111465 111134466
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 07:42:52, Gzip enabled