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 ...
随机推荐
- EF CodeFirst数据注解特性详解
数据注解特性是.NET特性,可以在EF或者EF Core中,应用于实体类上或者属性上,以重写默认的约定规则. 在EF 6和EF Core中,数据注解特性包含在System.ComponentModel ...
- SSM开发基于Java EE在线图书销售系统
SSM(Spring+Spring MVC+MyBatis)开发基于Java EE在线图书销售系统 网站成功建立和运行很大部分取决于网站开发前的规划,因此为了在网站建立过程中避免一些不 ...
- C++类几种初始化的顺序
首先给段代码: class A{ public: ; A():x(){cout<<"A(): x="<<x<<endl;} A(int a):x ...
- thinkphp中路由的基本使用
1.在application中下的config.php中 以下代码改为true // 是否开启路由 'url_route_on' => true, // 是否强制使用路由 'url_route_ ...
- git创建远程分支并推送
1.查看所有分支(-a=>'查看全部的分支') git branch -a 2.创建本地test分支 git branch test 2.2切换test分支 git checkout test ...
- 4.用springboot写的第一个程序--helloworld
这是我自己在controller层建的hello类 运行,选画方框的那个.我查了一晚上,可算知道为啥运行不了了. 然后再浏览器输入网址就ok了 为了大力!好好学习!
- Goahead WebSever 总结
编译成功后用http://127.0.0.1可以访问网站,若端口号不是默认的80,者访问时加“:端口”,如: http://127.0.0.1:8888 1.websHomePageHandler函数 ...
- 牛客竞赛第二场D Kth Minimum Clique 贪心+bitmap
Kth Minimum Clique 题意 给出n(n<100)个点的邻接表,和n个点的权值,求第k大的团(完全子图) 分析 n很小,并且好像没有什么算法和这个有关系,所以可以往暴力枚举的方向想 ...
- 【常识】常用RGB颜色对照表
RGB颜色表 白色:rgb(255,255,255) 黑色:rgb(0,0,0) 红色:rgb(255,0,0) 绿色:rgb(0,255,0) 蓝色:rgb(0,0,255) 青色:rgb(0,25 ...
- HTML学习(12)列表
HTML包括有序列表ol(ordered list).无序列表ul(unordered list).自定义列表dl(difinition list) 有序列表: <ol start=" ...