BITCNT - Bit count

Count the number of ones in bit repesentation of number.

Generate N number using formula (a*i+b)%c for all 1<=i<=n

limit: 1<=N<=1000000

0<=a*N, b*N<2^64

1<=c<2^64

Input

N

a b c

Output

[N numbers]

c1

c2

..

cn

 

Example

Input:
5
5 6 7

Output: 1
1
0
2
2

Explanation
Generated numbers are 4, 2, 0, 5, 3 and bit counts are 1, 1, 0, 2, 2 respectively

hints:
use unsigned long long

Added by:pankaj
Date:2011-02-10
Time limit:0.208s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:own

hide comments
2020-06-06 22:30:12
Unreasonable TL for a tutorial problem, AC in Python probably impossible.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.