ceil有毒啊。。用ceil一直错。

思路就是模拟吧,设当前的答案是ansx和ansy。

如果比例是小于ansx的,那么就要乘以一个倍数k1,使得a * k1 >= ansx的。

所以就用ceil(ansx / a)嘛。。然后一直wa。

ansy的同理,最后选一个倍数大的去乘就行了。

搞不清楚为什么用ceil会wa

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string> void work() {
int n;
cin >> n;
LL ansx = , ansy = ;
for (int i = ; i <= n; ++i) {
LL a, b;
cin >> a >> b;
LL k1 = ;
if (a < ansx) {
// k1 = max(k1, (LL)ceil(1.0 * ansx / a)); ceil有毒?
k1 = ansx / a;
if (ansx % a != ) k1++;
}
if (b < ansy) {
// k1 = max(k1, (LL)ceil(1.0 * ansy / b));
LL t = ansy / b;
if (ansy % b != ) t++;
k1 = max(k1, t);
}
ansx = a * k1;
ansy = b * k1;
}
cout << ansx + ansy << endl;
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}

C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report的更多相关文章

  1. AtCoDeerくんと選挙速報 / AtCoDeer and Election Report AtCoder - 2140 (按比例扩大)

    Problem Statement AtCoDeer the deer is seeing a quick report of election results on TV. Two candidat ...

  2. AtCoDeer and Election Report

    问题 G: AtCoDeer and Election Report 时间限制: 1 Sec  内存限制: 128 MB[提交] [状态] 题目描述 AtCoDeer the deer is seei ...

  3. 2018.09.19 atcoder AtCoDeer and Election Report(贪心)

    传送门 很有意思的一道贪心. 就是每次翻最小的倍数来满足条件. 代码: #include<bits/stdc++.h> #define ll long long using namespa ...

  4. AtCoder Regular Contest 062 E - AtCoDeerくんと立方体づくり / Building Cubes with AtCoDeer

    题目传送门:https://arc062.contest.atcoder.jp/tasks/arc062_c 题目大意: 给你\(N\)块正方形木板,每块木板四角有四种颜色(可以相同),木板中央有编号 ...

  5. 【AtCoder】ARC062

    ARC062 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report 每次看看比率至少变成多少倍能大于当前的数 然后就把两个人的票都改成那个数 #incl ...

  6. atcoder题目合集(持续更新中)

    Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarja ...

  7. FC红白机游戏列表(维基百科)

    1055个fc游戏列表 日文名 中文译名 英文版名 发行日期 发行商 ドンキーコング 大金刚 Donkey Kong 1983年7月15日 任天堂 ドンキーコングJR. 大金刚Jr. Donkey K ...

  8. Python学习 —— 爬虫入门 - 爬取Pixiv每日排行中的图片

    更新于 2019-01-30 16:30:55 我另外写了一个面向 pixiv 的库:pixiver 支持通过作品 ID 获取相关信息.下载等,支持通过日期浏览各种排行榜(包括R-18),支持通过 p ...

  9. [Arc062] Painting Graphs with AtCoDeer

    [Arc062] Painting Graphs with AtCoDeer Description 给定一张N点M边的无向图,每条边要染一个编号在1到K的颜色.你可以对一张染色了的图进行若干次操作, ...

随机推荐

  1. Posix线程编程指南(2)

    这是一个关于Posix线程编程的专栏.作者在阐明概念的基础上,将向您详细讲述Posix线程库API.本文是第2篇将向您讲述线程的创建与取消. 一.概念及作用在单线程程序中,我们经常要用到"全 ...

  2. AtCoder Grand Contest 013 C:Ants on a Circle

    题目传送门:https://agc013.contest.atcoder.jp/tasks/agc013_c 题目翻译 给你一个周长为\(L\)的圆,有\(N\)只蚂蚁在圆上爬,速度为一单位距离每秒. ...

  3. Python之模块介绍

    模块介绍 模块,是用一些代码实现的某个功能的代码集合. 类似与函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用,提供了代码的重用性和代码间的耦合.对于一个复杂的功能,可能需要多个函 ...

  4. 分布式环境下的session管理

    一.分布式Session的几种实现方式 1.1.基于cookie 进行session共享 简单.方便,每次通过判断cookie中的用户状态信息判断用户的登录状态:但是用户信息要存在客户端,存在安全隐患 ...

  5. 卸载 Ubuntu gnome 自带的 Videos, Browser, Document Viewer等

    卸载命令 # uninstall Browser sudo apt-get remove --purge webbrowser-app # uninstall Videos sudo apt-get ...

  6. unique()函数

    unique()是c++里面的一个去重函数,包含在<iostream>中. 该函数将重复的元素移至容器的末尾,返回的为前面的无重复项的尾地址. 由于返回的是地址,所以经常需要转换为数值使用 ...

  7. Linux下磁盘加密luks使用

    使用luks加密磁盘,磁盘需要映射才可以挂载,映射的时候需要输入密码验证.luks相对于是对硬盘上了一把锁,要想打开就得有相应的钥匙,如果打开了就可以随意操作了,和普通硬盘一样. 使用方法如下: 0. ...

  8. ASP.NET in C#,ClientScript.RegisterStartupScript与ClientScript.RegisterClientScriptBlock用法之己见

    ClientScript.RegisterStartupScript:http://msdn.microsoft.com/zh-cn/library/system.web.ui.clientscrip ...

  9. Jinkins定时任务设置

    设置的地方在构建触发器中 Build after other projects are built:在其他项目构建完成后再进行构建. Build periodically:周期进行构建 Build w ...

  10. OVS编译

    下载源码 # git clone https://github.com/openvswitch/ovs.git # cd ovs # git checkout branch-2.8 下载依赖包 # y ...