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 ...
随机推荐
- [ZJOI2014] 力 - 多项式乘法 FFT
题意:给定 \({q_i}\),求 \[E_i = \sum_{i<j}{\frac{q_j}{(j-i)^2}} - \sum_{i>j}{\frac{q_j}{(j-i)^2}}\] ...
- Weighted Visibility Graph With Complex Network Features in the Detection of Epilepsy
Their data five data set, 100 single channel of EEG signals, each channel EEG has 4097 data point. t ...
- C++ windows线程操作(转)
参考 1._beginthreadex创建线程 DWORD m_dwMSGTID; // 线程ID HANDLE m_hMSG; // 线程句柄 m_hMSG = (HANDLE)_beginthre ...
- 801. 二进制中1的个数(lowbit(n)函数)
给定一个长度为n的数列,请你求出数列中每个数的二进制表示中1的个数. 输入格式 第一行包含整数n. 第二行包含n个整数,表示整个数列. 输出格式 共一行,包含n个整数,其中的第 i 个数表示数列中的第 ...
- 1059 Prime Factors (25分)
1059 Prime Factors (25分) 1. 题目 2. 思路 先求解出int范围内的所有素数,把输入x分别对素数表中素数取余,判断是否为0,如果为0继续除该素数知道余数不是0,遍历到sqr ...
- Linux - Shell - shell 执行方式
概述 shell 的执行方式 背景 偶尔执行个 shell 脚本 一般都用 './script' 执行 最近忽然看到 有不同的执行方式, 感觉有必要整理一下, 然后和大家分享 准备 os centos ...
- MySQL表的操作01
表在数据库中主要用来实现存储数据记录,其基本操作包括创建表.查看表.删除表和修改表. 表中的数据库对象包括: 1.列(COLUMNS):也称属性列,在具体创建表时,必须指定列的名字和它的数据类型. 2 ...
- 【C语言】移动指针
移动指针 #include<stdio.h> int main() { char *s="哈哈哈哈哈哈"; for(*s;s!="\0";s++) ...
- 【New】WoSo_我搜 正式上线
[New]WoSo_我搜 正式上线 一站式搜索平台 聚合多种领域搜索引擎,大大提高搜索效率,使搜索更简单 地址:https://huangenet.github.io/WoSo/
- nomon+ pyNmonAnalyzer实现基于python的nmon监控性能数据可视化
pip install pyNmonAnalyzer nnmon for linux from sourceforge:https://sourceforge.net/projects/nmon/ ...