问题 G: AtCoDeer and Election Report

时间限制: 1 Sec  内存限制: 128 MB
[提交] [状态]

题目描述

AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≤i≤N) time, the ratio was Ti:Ai. It is known that each candidate had at least one vote when he checked the report for the first time.
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.

输入

The input is given from Standard Input in the following format:
N
T1 A1
T2 A2
:
TN AN

输出

Print the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.

样例输入
Copy

3
2 3
1 1
3 2

样例输出 Copy

10

提示

When the numbers of votes obtained by the two candidates change as 2,3→3,3→6,4, the total number of votes at the end is 10, which is the minimum possible number.
 
题意:就是两个人进行投票每一次都只显示投票比例
AC代码:
#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的更多相关文章

  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. 2018.09.19 atcoder AtCoDeer and Election Report(贪心)

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

  3. C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

    ceil有毒啊..用ceil一直错. 思路就是模拟吧,设当前的答案是ansx和ansy. 如果比例是小于ansx的,那么就要乘以一个倍数k1,使得a * k1 >= ansx的. 所以就用cei ...

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

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

  5. 【AtCoder】ARC062

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

  6. 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 ...

  7. [译]ZOOKEEPER RECIPES-Leader Election

    选主 使用ZooKeeper选主的一个简单方法是,在创建znode时使用Sequence和Ephemeral标志.主要思想是,使用一个znode,比如"/election",每个客 ...

  8. 2.ASP.NET MVC 中使用Crystal Report水晶报表

    上一篇,介绍了怎么导出Excel文件,这篇文章介绍在ASP.NET MVC中使用水晶报表. 项目源码下载:https://github.com/caofangsheng93/CrystalReport ...

  9. Monthly Income Report – August 2016

    原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...

随机推荐

  1. 使用正则提取字符串中URL等信息

    一.说明 背景:最近在做同步京东商品信息时遇到一个问题,同步后的商品详情无法在富文本中修改,强制修改会导致图片无法正常显示,研究发现详情中的图片是在css的作为背景图指定的. 解决:经过多次尝试,最后 ...

  2. Maven设置阿里云镜像

    <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...

  3. 跨表更新,Mysql Update Join

    背景 项目新导入了一批人员数据,这些人的有的部门名称发生了变化,有的联系方式发生了变化,暂且称该表为t_dept_members, 系统中有另外一张表 t_user_info 记录了人员信息. 要求将 ...

  4. 初识eclipse-java

    开始时会有工程的地址需要设置,最好将程序放在一个单独的文件夹中 有时候会用到外部的驱动程序,如excel等,就需要导入jar包 具体的请看下篇博客.

  5. ubuntu18.04双卡机安装ubidia驱动遇到的坑

    在ubuntu 18的软件更新中选择英伟达驱动进行安装,输入nvidia-smi总是提示缺少驱动,未驱动之类的报错. 何解? 最初以为安装系统的问题,重装ubuntu也未果. 最后查了很多资料,找到一 ...

  6. List数组排序

    import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.u ...

  7. requests.packages.urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme

    python3 -m pip install -U requests[socks]

  8. 算法_hdoj_1005

    Question: Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 6 ...

  9. Mongo查询list数组中一个字段大于特定条数

    由于刚刚接触mongodb,很多语法还不是很了解,写的不好的地方请大佬指出 查询的demo数据 { "_id":Object("xxxxxxxx"), &quo ...

  10. Codeforces Round #619 (Div. 2)C(构造,容斥)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; int main(){ ios::syn ...