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. dsu on tree(无讲解)

    CF741D. Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 分析: 最多有一个字符出现奇数次 维护某个状态下深度的最大值,注意 ...

  2. css3渐变gradient

    参考: http://www.w3cplus.com/content/css3-gradient

  3. POJ1511(最短路大数据处理)

    Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 23357   Accepted: 767 ...

  4. java项目文件的路径问题

    title: 项目下的路径问题 tags: grammar_cjkRuby: true --- 在javaee的项目中,存取文件,解析xml和properties文件,以及项目中的文件,都需要获取路径 ...

  5. Python中日志的格式化输出

    import logging logfile = 'e:\\a.txt' # logging.basicConfig(filename=logfile,level=logging.INFO) # lo ...

  6. iOS :undefined symbols for architecture x86_64

    转自:http://www.th7.cn/Program/IOS/201408/268371.shtml 问题描述:为了适配iPhone 5s的64位处理器,在编译选项中加入了arm64架构.但是发现 ...

  7. repackage android application

    decompile the application file apktool d -o dianping/ dianping.apk modify the resources / smali asse ...

  8. bootstrap下拉框式标签页

    <ul id="myTab" class="nav nav-tabs"> <li class="active"> & ...

  9. CSU - 1580 NCPC2014 Outing(树形依赖+分组背包)

    Outing Input Output Sample Input 4 4 1 2 3 4 Sample Output 4 分组背包: for 所有的组k for v=V..0 for 所有的i属于组k ...

  10. HDU - 1150 POJ - 1325 Machine Schedule 匈牙利算法(最小点覆盖)

    Machine Schedule As we all know, machine scheduling is a very classical problem in computer science ...