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 of Sequence

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 2617    Accepted Submission(s): 910


Problem Description
Alice is playing a game with Bob.
Alice shows N integers a1, a2, ¡­, aN, and M, K. She says each integers 1 ¡Ü ai ¡Ü M.
And now Alice wants to ask for each d = 1 to M, how many different sequences b1, b2, ¡­, bN. which satisfies :
1. For each i = 1¡­N, 1 ¡Ü b[i] ¡Ü M
2. gcd(b1, b2, ¡­, bN) = d
3. There will be exactly K position i that ai != bi (1 ¡Ü i ¡Ü n)

Alice thinks that the answer will be too large. In order not to annoy Bob, she only wants to know the answer modulo 1000000007.Bob can not solve the problem. Now he asks you for HELP!
Notes: gcd(x1, x2, ¡­, xn) is the greatest common divisor of x1, x2, ¡­, xn
 

Input
The input contains several test cases, terminated by EOF.
The first line of each test contains three integers N, M, K. (1 ¡Ü N, M ¡Ü 300000, 1 ¡Ü K ¡Ü N)
The second line contains N integers: a1, a2, ..., an (1 ¡Ü ai ¡Ü M) which is original sequence.

 

Output
For each test contains 1 lines :
The line contains M integer, the i-th integer is the answer shows above when d is the i-th number.
 

Sample Input
3 3 3 3 3 3 3 5 3 1 2 3
 

Sample Output
7 1 0 59 3 0 1 1
 

Hint

In the first test case :
when d = 1, {b} can be :
(1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 2, 2)
(2, 1, 1)
(2, 1, 2)
(2, 2, 1)
when d = 2, {b} can be :
(2, 2, 2)
And because {b} must have exactly K number(s) different from {a}, so {b} can't be (3, 3, 3), so Answer = 0
 

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 20:55:38, Gzip enabled