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 

题意:给定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 ;
}

Codeforces Round #240 (Div. 2) B 好题的更多相关文章

  1. Codeforces Round #609 (Div. 2)前五题题解

    Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...

  2. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  3. Codeforces Round #310 (Div. 2)--A(简单题)

    http://codeforces.com/problemset/problem/556/A 题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1. 题解:统计所有的0有多少个,1有多少 ...

  4. Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)

    A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  5. Codeforces Round #336 (Div. 2)-608A.水题 608B.前缀和

    A题和B题...   A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabyte ...

  6. Codeforces Round #316 (Div. 2) (ABC题)

    A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序) ...

  7. Codeforces Round #240 (Div. 2) C Mashmokh and Numbers

    , a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...

  8. Codeforces Round #240 (Div. 2) 题解

    A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...

  9. Codeforces Round #590 (Div. 3)【D题:26棵树状数组维护字符出现次数】

    A题 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值. AC代码: #includ ...

随机推荐

  1. IE脚本调试

    打开IE -- 工具 -- Internet选项 -- 高级 --有4项. 1.禁用脚本调试(Internet Explorer)(去掉对勾) 2.禁用脚本调试(其他)(去掉对勾) 3.显示每个脚本错 ...

  2. python 写 组合两两组合

    紧挨着 组合  a b c d  ----> ab ,bc ,cd portList = ['a', 'b', 'c', 'd'] for i, p in enumerate(portList) ...

  3. linux运维、架构之路-MySQL多实例

    一.MySQL多实例介绍            一台服务器上开启多个不同的服务端口(3306,3307,3308),运行多个MySQL服务进程,共用一套MySQL安装程序,多实例MySQL在逻辑上看是 ...

  4. vue.js 图片预览

    Vue.js的图片预览的插件还是不少,但是找了半天还是没找到跟现在项目里能用得很顺手的,其实项目里图片预览功能很简单,点击放大,能双指缩放就可以了.部分vue.js的图片预览库都需要把图片资源单独拿出 ...

  5. JZOJ 3382. 【NOIP2013模拟】七夕祭

    3382. [NOIP2013模拟]七夕祭 Time Limits: 1000 ms  Memory Limits: 131072 KB  Detailed Limits   Goto Problem ...

  6. 第15课 栏目的排序处理(组件化) Thinkphp5商城第四季

    目录 要实现的功能 思路: 视图层 控制器里: 扩展函数里 要实现的功能 用表单里的提交过来的sort数据,批量修改表里的排序值 界面效果: 思路: 视图层表单提交数据主键=>sort值 控制器 ...

  7. 精通SpringBoot---整合RabbitMQ消息队列

    今天来和朋友们一起学习下,SpringBoot怎么整合RabbitMQ.目前消息组件大致有三种:.activemq, rabbitmq, kafka.这三者各有优缺点,RabbitMQ相比之下是处于其 ...

  8. OAuth2.0 social_django微博第三方登录

    python网站第三方登录,social-auth-app-django模块, social-auth-app-django模块是专门用于Django的第三方登录OAuth2协议模块 目前流行的第三方 ...

  9. Admin站点

    使用admin站点 a.在settings.py中设置语言和时区 LANGUAGE_CODE = 'zh-hans' # 使用中国语言 TIME_ZONE = 'Asia/Shanghai' # 使用 ...

  10. Gym - 101908G Gasoline 二分+最大流

    G - Gasoline Gym - 101908G 题意:给出R个提供点,P个接收点,每个接收点都要接收满,还有一个运输的时间,问最小时间能够完成所有的运输 题解:首先每次都必须要满流,所以我们只要 ...