数学——415B. Mashmokh and Tokens

---恢复内容开始---

B. Mashmokh and Tokens
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 back w 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 contains n 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.

Examples
input
5 1 4
12 6 11 9 1
output
0 2 3 1 1 
input
3 1 2
1 2 3
output
1 0 1 
input
1 1 1
1
output
0 

题意:老板每天给员工Xi代金券,员工可以用代金券换取现金,所获得的现金是
 ,w是给老板的代金券。现在要求:用每天的代金券尽量换取多的现金,最多可以省下多少现金券。
题解:先求w*a%b,因为w*a/b就是能得到的最多的钱,%b则可以求出所得钱最多的同时可以剩下“多少”,不过剩下的是乘a后的数量,所以还需要再除a.
/*B*/
#include<cstdio>
#include<cstring>
using namespace std;

const int maxn=100000+100;
int main()
{
    long long  n,a,b;
    long long x[maxn];
    while(scanf("%I64d%I64d%I64d",&n,&a,&b)!=EOF)
    {
        for(int i=0;i<n;i++)
            scanf("%I64d",&x[i]);
        long long ans[maxn];
        for(int i=0;i<n;i++)
        {
            long long temp=x[i]*a%b;
            ans[i]=temp/a;
        }
        for(int i=0;i<n;i++)
            printf("%I64d ",ans[i]);
        printf("\n");
    }
    return 0;
}

 

 

 

转载于:https://www.cnblogs.com/yepiaoling/p/5316794.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值