C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
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的更多相关文章
- AtCoDeerくんと選挙速報 / AtCoDeer and Election Report AtCoder - 2140 (按比例扩大)
Problem Statement AtCoDeer the deer is seeing a quick report of election results on TV. Two candidat ...
- AtCoDeer and Election Report
问题 G: AtCoDeer and Election Report 时间限制: 1 Sec 内存限制: 128 MB[提交] [状态] 题目描述 AtCoDeer the deer is seei ...
- 2018.09.19 atcoder AtCoDeer and Election Report(贪心)
传送门 很有意思的一道贪心. 就是每次翻最小的倍数来满足条件. 代码: #include<bits/stdc++.h> #define ll long long using namespa ...
- AtCoder Regular Contest 062 E - AtCoDeerくんと立方体づくり / Building Cubes with AtCoDeer
题目传送门:https://arc062.contest.atcoder.jp/tasks/arc062_c 题目大意: 给你\(N\)块正方形木板,每块木板四角有四种颜色(可以相同),木板中央有编号 ...
- 【AtCoder】ARC062
ARC062 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report 每次看看比率至少变成多少倍能大于当前的数 然后就把两个人的票都改成那个数 #incl ...
- atcoder题目合集(持续更新中)
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarja ...
- FC红白机游戏列表(维基百科)
1055个fc游戏列表 日文名 中文译名 英文版名 发行日期 发行商 ドンキーコング 大金刚 Donkey Kong 1983年7月15日 任天堂 ドンキーコングJR. 大金刚Jr. Donkey K ...
- Python学习 —— 爬虫入门 - 爬取Pixiv每日排行中的图片
更新于 2019-01-30 16:30:55 我另外写了一个面向 pixiv 的库:pixiver 支持通过作品 ID 获取相关信息.下载等,支持通过日期浏览各种排行榜(包括R-18),支持通过 p ...
- [Arc062] Painting Graphs with AtCoDeer
[Arc062] Painting Graphs with AtCoDeer Description 给定一张N点M边的无向图,每条边要染一个编号在1到K的颜色.你可以对一张染色了的图进行若干次操作, ...
随机推荐
- hdu-5857 Median(水题)
题目链接: Median Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- python2.7 爬虫初体验爬取新浪国内新闻_20161130
python2.7 爬虫初学习 模块:BeautifulSoup requests 1.获取新浪国内新闻标题 2.获取新闻url 3.还没想好,想法是把第2步的url 获取到下载网页源代码 再去分析源 ...
- ACM学习历程—NPU1045 2015年陕西省程序设计竞赛网络预赛(热身赛)C题 Graph Theory(递推 && 组合数学 && 大数)
Description In graph theory, a matching or independent edge set in a graph G = (V , E) is a set of e ...
- [Codeforces 452E] Three Strings
[题目链接] https://codeforces.com/contest/452/problem/E [算法] 构建后缀数组 用并查集合并答案即可 时间复杂度 : O(NlogN) [代码] #in ...
- Poj_1068 Parencodings
S (((( )( )() ) ) ) P-sequence 4 5 6666,表示第i个右括号的左边有几个左括号. W-sequence 1 1 1456,表示第i个右括号和以 ...
- spring boot 学习三:OAuth2 认证
1: 代码地址: https://github.com/liufeiSAP/uaa-zuul 2: 安装: postgres 下载 https://www.openscg.com/bigsq ...
- 整理出来的一个windows关机、锁定、重启、注销 API调用
using System.Runtime.InteropServices; namespace HookDemo { class WindowsExit { [StructLayout(LayoutK ...
- Redis 教程笔记
简介: 开源BSD.key-value数据库.数据持久化(可将内存数据保存到磁盘中),提供多种数据结构. 支持数据备份(master-slave模式) 优势: 性能高.数据类型丰富.原子性.其他 Re ...
- Python list的定义和删改
需要用到list.取回参数 . sys.argv返回的是个元组. 最后发现用for循环好像没用. a=0 for i in sys.argv[1:]: qh[a]=sys.argv[a] a=a+1 ...
- (十四)hibernate逆向工程
一.hibernate逆向工程生成实体 介绍一个模型设计工具PowerDesigner,这个是j2ee开发必要的一个工具.一般在开发中先使用PowerDesigner 创建实体关系图即概念模型.建立了 ...