codeforces 415B Mashmokh and Tokens

网友投稿 227 2022-09-21

codeforces 415B Mashmokh and Tokens

B. Mashmokh and Tokens

time limit per test

memory limit per test

input

output

n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get

dollars.

n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n

Input

n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains nspace-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109).

Output

n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.

Examples

input

5 1 412 6 11 9 1

output

0 2 3 1 1

input

3 1 21 2 3

output

1 0 1

input

1 1 11

output

0

题意是用token去换钱..

是w*a/b向下取整,在换到最多钱的同时留下最多token..

最多换到的钱为w*a/b,因为会有余数所以要求出x

所以w*a%b便能求出其余数..然后用余数除a就得出余数所占得token..

#include#include#include#includeusing namespace std;#define N 100000int main(){ long long int t[N],p[N],a,b,n,i,j; scanf("%lld %lld %lld",&n,&a,&b); for(i=1;i<=n;i++) { cin>>t[i]; p[i]=((t[i]*a)%b)/a; } for(i=1;i<=n;i++) { cout<

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:写给Rikka自己的RxJava2说明书
下一篇:丁道师:共享自习室会是下一个创业风口浪潮吗?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~