首页 技术 正文
技术 2022年11月13日
0 收藏 844 点赞 3,065 浏览 1734 个字

B. Mashmokh and Tokenstime 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 Codeforces Round #240 (Div. 2) B  好题 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.

ExamplesInput

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 题意:给定a,b  x块可以换 x*a/b(向下取整)美元 问你每天最多节省最多的块 拿到最多的美元
输出块数
题解:能拿到的美元最多为t=x*a/b 因为是向下取整 所以t<=x*a/b 现在要找到一个最小的x 使得满足不等式
x替换y t<=y*a/b 所以 y>=t*b/a x-y即为所求这里需要特判
if(t*b%a)
ans[i]=aa[i]-((t*b)/a+1); //若t*b%a不为零 为满足 y>=t*b/a 需要增一 这是考虑等编程语言的除法取整
else
ans[i]=aa[i]-((t*b)/a);
 #include<bits/stdc++.h>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
#define bug(x) printf("%%%%%%%%%%%%%",x);
#define inf 1e8
using namespace std;
ll n,a,b;
ll t;
ll aa[];
ll ans[];
int main()
{
scanf("%I64d %I64d %I64d",&n,&a,&b);
for(ll i=;i<=n;i++)
{
scanf("%I64d",&aa[i]);
t=(aa[i]*a)/b;
if(t*b%a)
ans[i]=aa[i]-((t*b)/a+);
else
ans[i]=aa[i]-((t*b)/a);
}
printf("%I64d",ans[]);
for(int i=;i<=n;i++)
printf(" %I64d",ans[i]); return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,913
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,438
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,252
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,063
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,695
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,733