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

Can you find it

Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2521    Accepted Submission(s): 1034


Problem Description
Given a prime number $C(1 \leq C \leq 2\times 10^5)$, and three integers k1, b1, k2 $(1 \leq k1, k2, b1 \leq 10^9)$. Please find all pairs (a, b) which satisfied the equation $a^{k1 \cdot n + b1}$ + $b^{k2 \cdot n - k2 + 1}$ = 0 (mod C)(n = 1, 2, 3, ...).
 

Input
There are multiple test cases (no more than 30). For each test, a single line contains four integers C, k1, b1, k2.
 

Output
First, please output "Case #k: ", k is the number of test case. See sample output for more detail.
Please output all pairs (a, b) in lexicographical order. $(1 \leq a, b < C)$. If there is not a pair (a, b), please output -1.
 

Sample Input
23 1 1 2
 

Sample Output
Case #1: 1 22
 

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-21 21:31:02, Gzip enabled