Codeforces Round #240 (Div. 2) B;http://codeforces.com/problemset/problem/415/B

题意:老板一天发x张代币券,员工能用它来换大洋,用w张代币券可换[a*w/b](下取整)块大洋,代币券只能当天适用,求换最多大洋时最多能留多少代币券

比如a=3,b=7,x=4时,我最多能换3×4/7=1块大洋,但是我显然用3张代币券就能换1块大洋,所以多的1块就应该被保留。

题解:就是找一个w0,使得a*(w-w0)/b最接近a*w/b;推到过程很巧妙,最终的结果就是a*w%b/a,注意用long long.

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+;
long long c[N];
int n;
long long a,b;
int main(){
while(~scanf("%d%I64d%I64d",&n,&a,&b)){
for(int i=;i<=n;i++){
scanf("%I64d",&c[i]);
}
for(int i=;i<=n;i++){
if(i==n)printf("%I64d\n",(c[i]*a)%b/a);
else{
printf("%I64d ",(c[i]*a)%b/a);
}
}
}
}

Mashmokh and Tokens的更多相关文章

  1. Codefroces 415B Mashmokh and Tokens

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

  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. CF Round#240题解

    第一次参加CF的比赛,MSK19.30,四个小时的时差真心累,第一次CODE到这么夜-- 一开始做了A,C两题,后来做B题的时候我体力和精神集中度就很低了,导致一直WA在4-- 今天起床后再刷B,终于 ...

  4. Codeforces Round #240 (Div. 2) B 好题

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

  5. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  6. [译] ASP.NET MVC 6 attribute routing – the [controller] and [action] tokens

    原文:http://www.strathweb.com/2015/01/asp-net-mvc-6-attribute-routing-controller-action-tokens/ 当在Web ...

  7. Unable to establish connection to tokens

    安装openstack后遇到的第一个问题. 执行命令nova list得到如下结果: [root@localhost ~(keystone_admin)]# nova list No handlers ...

  8. JSON WEB TOKENS

    用JWT来保护我们的ASP.NET Core Web API   在上一篇博客中,自己动手写了一个Middleware来处理API的授权验证,现在就采用另外一种方式来处理这个授权验证的问题,毕竟现在也 ...

  9. Delphi XE5教程11:Tokens

    内容源自Delphi XE5 UPDATE 2官方帮助<Delphi Reference>,本人水平有限,欢迎各位高人修正相关错误!也欢迎各位加入到Delphi学习资料汉化中来,有兴趣者可 ...

随机推荐

  1. [Redux] Persisting the State to the Local Storage

    We will learn how to use store.subscribe() to efficiently persist some of the app’s state to localSt ...

  2. [Redux] Supplying the Initial State

    We will learn how to start a Redux app with a previously persisted state, and how it merges with the ...

  3. [AngularJS + Webpack] Requiring Templates

    With Angular, most of the time you're specifying a templateUrl for your directives and states/routes ...

  4. 将html中的br换行符转换为文本输入中的换行符(转)

    PHP中的有个非常好的函数:nl2br(),将文本框中的换行转换为HTML页面的<br />,但是如何实现将html中的<br />换行符转换为文本框中的换行符呢?下面这几个方 ...

  5. linux安装总结(亲测)

    一:磁盘分区情况 NTFS,FAT32 这是两种常用的磁盘格式 windows7自带的磁盘工具也可以分出上面的格式,用软件也可以.但是FAT32最大的复制文件进去的限度时4G. EXT3只能用软件才能 ...

  6. 『零行代码』解决键盘遮挡问题(iOS)

    关注仓库,及时获得更新:iOS-Source-Code-Analyze https://github.com/draveness/iOS-Source-Code-Analyze Follow: Dra ...

  7. xslt语法之---If Else

    大家都知道,XSL中是没有if else的,那么要想实现if else该怎么办呢? 其实很简单 <xsl:choose> <xsl:when test="position( ...

  8. ASP.NET图片验证码

    1. 新建一个Validate.aspx,然后在Validate.aspx.cs编写代码: using System; using System.Collections; using System.C ...

  9. bootstrap3学习1:响应式布局layout

    在去年的这个时候写过关于bootstrap的相关文章(见:bootstrap2学习1:基本CSS样式),然后就搁置了,原因是因为当时对bootstrap的了解不深,并且当时v2版本对响应式设计的不是非 ...

  10. sqlserver 时间转换

    sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(), 时间一, ) 结果:-- :/*时间一般 ...