AtCoDeer and Election Report
题目描述
Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
Constraints
1≤N≤1000
1≤Ti,Ai≤1000(1≤i≤N)
Ti and Ai (1≤i≤N) are coprime.
It is guaranteed that the correct answer is at most 1018.
输入
N
T1 A1
T2 A2
:
TN AN
输出
样例输入
Copy
3
2 3
1 1
3 2
样例输出 Copy
10
提示
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){ll x=,f=;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-;for(;isdigit(c);c=getchar()) x=x*+c-'';return x*f;}
const int maxn=;
const int M=1e7+;
const int INF=0x3f3f3f3f;
int main()
{
ll n,sum1=,sum2=,i;
ll a,b,t,m;
cin>>n;
sum1=;
sum2=;
for(i=;i<=n;i++)
{
scanf("%lld%lld",&a,&b);
t=;
if(sum1>a)
{
t=sum1/a;
if(sum1%a!=)
t++;
}
if(sum2>b)
{
m=sum2/b;
if(sum2%b!=)
m++;
t=max(t,m);
}
sum1=a*t;
sum2=b*t;
}
printf("%lld\n",sum1+sum2);
return ;
}
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 ...
- 2018.09.19 atcoder AtCoDeer and Election Report(贪心)
传送门 很有意思的一道贪心. 就是每次翻最小的倍数来满足条件. 代码: #include<bits/stdc++.h> #define ll long long using namespa ...
- C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
ceil有毒啊..用ceil一直错. 思路就是模拟吧,设当前的答案是ansx和ansy. 如果比例是小于ansx的,那么就要乘以一个倍数k1,使得a * k1 >= ansx的. 所以就用cei ...
- atcoder题目合集(持续更新中)
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarja ...
- 【AtCoder】ARC062
ARC062 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report 每次看看比率至少变成多少倍能大于当前的数 然后就把两个人的票都改成那个数 #incl ...
- A Bayesian election prediction, implemented with R and Stan
If the media coverage is anything to go by, people are desperate to know who will win the US electio ...
- [译]ZOOKEEPER RECIPES-Leader Election
选主 使用ZooKeeper选主的一个简单方法是,在创建znode时使用Sequence和Ephemeral标志.主要思想是,使用一个znode,比如"/election",每个客 ...
- 2.ASP.NET MVC 中使用Crystal Report水晶报表
上一篇,介绍了怎么导出Excel文件,这篇文章介绍在ASP.NET MVC中使用水晶报表. 项目源码下载:https://github.com/caofangsheng93/CrystalReport ...
- Monthly Income Report – August 2016
原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...
随机推荐
- ORA-01843: not a valid month
问题描述 ORA-01843: not a valid month oracle数据库插入出现无效的月份
- linux异常 - 网卡故障
问题描述: 弹出界面eth0: 错误:没有找到合适的设备:没有找到可用于链接System eth0 的设备 解决方案: 排错步骤如下: 1:查看系统是否识别相应网卡(发现没有eth0网卡存在): 根据 ...
- js获取当前页面的url网址信息
设置或获取整个 URL 为字符串: window.location.href 获取内容:http://10.100.0.8:7000/SVP/ "window.location.href&q ...
- Log4j的isdebugEnabled的作用
转自:https://www.iteye.com/blog/zhukewen-java-1174017 在项目中我们经常可以看到这样的代码: if (logger.isDebugEnabled()) ...
- 【转载】Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
转自:http://www.linuxidc.com/Linux/2014-03/98978.htm Pig 一种操作hadoop的轻量级脚本语言,最初又雅虎公司推出,不过现在正在走下坡路了.当初雅虎 ...
- 诡异的BUG
1.今天遇到一个诡异的BUG(一个很古老的项目),为什么说他诡异呢,我们本地都是OK的,但是现场部署就会报错? 2.描述下现象其实这个问题不难定位(关键是有个jar包没有源码不能进行验证性的编译) 我 ...
- SpringMVC框架应用
SSMSpringMVC框架 1. MVC设计模式:模型.视图.控制器: 视图:负责格式化数据并把他们呈现给用户,包括数据展示.用户交互.数据验证.界面设计等功能.对应组件:JSP或者HTML ...
- c# DPI SCale
public class Screen { /// Primary Screen #region Win32 API [DllImport("user32.dll")] stati ...
- 接口出现无法执行curl 开启cgi
问题描述: 路由能正常访问,但认证失败, 由于请求需要执行,curl -X GET "http://api.jr.com/v1/salary/list" -H "acce ...
- bzoj 1036: [ZJOI2008]树的统计Count (树链剖分)
ps:这道题过的人真多啊 一道树剖的模板题 (好像还可以用lct做, 然而我并不会 代码如下 /**************************************************** ...