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

Product

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 287    Accepted Submission(s): 50
Special Judge


Problem Description
You are given a prime $p$. For a number $a$, you need to find positive integers $x_1, x_2, \dots, x_k$ such that $\prod x_i \equiv a \pmod p$, and $\sum x_i\leq 2500$. Output any valid solution.
 

Input
The first line contains a prime $p (1\leq p \leq 10^{18})$, $p$ is chosen uniformly and randomly from $[0.9\times 10^{18}, 10^{18}]$.

The second line contains a integer $q (1\leq q\leq 100)$. Each line of the following $q$ lines contains an integer $a (1\leq a\leq p-1)$, $a$ is chosen from $[1, p-1]$ uniformly and randomly.
 

Output
Output $q$ lines for each number. In each line, prine $k$ first, then $x_1, x_2, \dots, x_k$.
 

Sample Input
178187 3 6 100 109065
 

Sample Output
2 2 3 1 100 2 1000 1000
 

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 19:33:05, Gzip enabled