cf——B. Mashmokh and Tokens

来源:互联网 发布:金山数据恢复人电话 编辑:程序博客网 时间:2024/06/05 00:38

Bimokh is Mashmokh's boss. For the following 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 backw tokens then he'll get  dollars.

Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has 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 days the number of tokens he can save.

Input

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

Output

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

Sample test(s)
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 
#include<iostream>#include <cstring>#include <algorithm>using namespace std;int main(){    long long n,a,b,t,y;    cin>>n>>a>>b;    for(int i=0;i<n;i++)    {        int x;        cin>>x;        t=x*a/b;        if(t*b%a==0)        {            y=t*b/a;        }        else        y=t*b/a+1;        cout<<x-y<<" ";    }    cout<<endl;    return 0;}


0 0
原创粉丝点击