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. POJ1330Nearest Common Ancestors——近期公共祖先(离线Tarjan)

    http://poj.org/problem? id=1330 给一个有根树,一个查询节点(u,v)的近期公共祖先 836K 16MS #include<iostream> #includ ...

  2. Python获取当前时间 分类: python 2014-11-08 19:02 132人阅读 评论(0) 收藏

    Python有专门的time模块可以供调用. <span style="font-size:14px;">import time print time.time()&l ...

  3. db4o官方停止支持及面向对象数据库的一些感想

    前一段时间试用了db4o,真心认为不错.但自己在国内搜索了一下,并没有找到不论什么一个专门的论坛和面向对象的数据库产品.深感这东西在国内并没有太普及. 但自己试用认为这个东东真心不错(当然也有自己的优 ...

  4. [AngularJS + Webpack] Requiring Templates

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

  5. javascript实现无缝上下滚动(转)

    js实现上下无缝滚动的原理是这样的: 1.首先给容器设定高度或宽度,然后overflow:hidden: 2.容器高度设定后,内容超出则被隐藏.3.改变容器的scrollTop(上下滚动)属性的值,让 ...

  6. CentOS iSCSI客户端使用配置

    配置步骤: 1.查看安装是否安装iSCSI驱动 rpm -qa|grep iscsi 2.查看yum安装源 yum list |grep iscsi 3.安装iscsi驱动 yum install i ...

  7. Java theory and practice: Thread pools and work queues--reference

    Why thread pools? Many server applications, such as Web servers, database servers, file servers, or ...

  8. python版本简历

  9. iBatis 的插入一个实体

    Student.xml 这个制定参数的属性 <insert id="insertStudent" parameterClass="Student" > ...

  10. JAVA DATE解析(时间戳解析为固定格式)

    public class SimpleDateFormat extends DateFormat SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (d ...