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 ...
随机推荐
- PAT (Basic Level) Practise (中文)- 1002. 写出这个数 (20)
http://www.patest.cn/contests/pat-b-practise/1002 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个 ...
- 关于后台获取不到HiddenField值的有关问题
服务器加载aspx程序时,首先要执行后台cs文件中的page_load等方法中的代码,其它按钮事件等是不执行的,生成页面发送到客户端.客户端执行时会响应js脚本,提交到服务器后除了执行page_loa ...
- 记录一些 FileZillaClient 的基本连接操作
本地主机:Window 10 FileZilla版本:3.39.0 64位 远程主机:CentOS 6.4 需安装FTP服务 小提示:查看CentOS版本命令 # cat /etc/issue Fil ...
- centos7上mysql8.0rpm方式安装
首先是下载图解 1.首先卸载centos7中自带的mariadb rpm -qa|grep mariadb //查询出来已安装的mariadb rpm -e --nodeps 文件名 //卸载mari ...
- tcl之list操作-lappend/lsearch/lsort/concat/split/join/
- django admin模块使用
BBS之admin组件的使用 1.创建超级管理员 创建超级管理员 一. tools>>>>runmanagepyTask>>>>>createsu ...
- stm32 flash和sram
FLASH是用来存储程序的,SRAM是用来存储程序运行中的中间变量
- java十分钟速懂知识点——System类
上次面试中遇到的一个问题,问到System.out.println()中的out是不是内部类,当时就给问蒙了,直观感觉out应该是System类的一个属性,跟内部类有什么关系?而且之前整理IO部分的时 ...
- TCP/IP网络编程之网络编程和套接字
网络编程和套接字 网络编程又称为套接字编程,就是编写一段程序,使得两台连网的计算机彼此之间可以交换数据.那么,这两台计算机用什么传输数据呢?首先,需要物理连接,将一台台独立的计算机通过物理线路连接在一 ...
- tensorboard页面显示No dashboards are active for current data set 问题win10系统
如果问题如上所示,可以试下如下方法: 在文件夹中找到你的logs文件, 在空白处按住“shift”键,右键鼠标(注意鼠标不要选中任何文件),点击“Powershell”打开win10powershel ...