Codeforces Round #240 (Div. 2) B 好题
1 second
256 megabytes
standard input
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.
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 n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.
5 1 4
12 6 11 9 1
0 2 3 1 1
3 1 2
1 2 3
1 0 1
1 1 1
1
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 好题的更多相关文章
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- Codeforces Round #240 (Div. 2)(A -- D)
点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...
- Codeforces Round #310 (Div. 2)--A(简单题)
http://codeforces.com/problemset/problem/556/A 题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1. 题解:统计所有的0有多少个,1有多少 ...
- 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 ...
- 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 ...
- Codeforces Round #316 (Div. 2) (ABC题)
A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序) ...
- 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 ...
- Codeforces Round #240 (Div. 2) 题解
A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...
- Codeforces Round #590 (Div. 3)【D题:26棵树状数组维护字符出现次数】
A题 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值. AC代码: #includ ...
随机推荐
- git出现误修改如何撤销
场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file. 场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步, ...
- SummerVocation_Learning--java的String类方法总结
壹: public char charAt(int index),返回字符串中第index个字符. public int length(), 返回字符串长度. public int indexOf(S ...
- python 实现简单语音聊天机器人
'''思路:使用百度的文本转音频API,将结果保存成mp3格式,并用mp3play库播放该文件.''' 1 # -*- coding:utf-8 -*- import sys import reque ...
- 制定RPM包和加入YUM源
##################################################### ##如有转载,请务必保留本文链接及版权信息 ##欢迎广大运维同仁一起交流linux/unix ...
- HTML5页面元素中的文本最快速替换replace()方法
$.ajax({ type:"get", url:spanUrl, dataType:'jsonp', jsonpCallback:'jsonp',//jsonp数据,需要数据库提 ...
- JZOJ 2136. 【GDKOI2004】汉诺塔
2136. [GDKOI2004]汉诺塔 (Standard IO) Time Limits: 3000 ms Memory Limits: 128000 KB Detailed Limits ...
- 科学计算库Numpy——运算
np.multiply(array1,array2) 该函数用于数组中对应位置上的数相乘. 一维向量 二维数组 np.dot(array1,array2) 两个数组都是一维向量 数组中对应位置上的数相 ...
- exec , 元类,__new__, __call__ , 单例模式 , 异常
1,类也是对象 ''' 动态语言 可以在运行期间 动态生成类 修改对象属性 静态语言 ''''' ''' type(object_or_name, bases, dict) type(object) ...
- 下载速度更加快的 SourceForge 镜像
http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/是 University of Kent的镜像, ...
- python中迷茫的编码问题
1.理清一些知识点: python默认的编码格式: ASCII(py2) unicode(py3) 查看默认编码:sys.defaultencoding 修改默认编码:#coding = utf-8 ...