Submission #927751


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    int n; cin>>n;
    LL x, y; cin>>x>>y;
    repn(i, n-1) {
        LL u, v; cin>>u>>v;
        LL times=max((x-1)/u+1, (y-1)/v+1);
        x=u*times, y=v*times;
    }
    cout<<(x+y)<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User fqw
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1753 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 3 ms 256 KB
0_001.txt AC 3 ms 256 KB
0_002.txt AC 2 ms 256 KB
1_003.txt AC 3 ms 256 KB
1_004.txt AC 3 ms 256 KB
1_005.txt AC 3 ms 256 KB
1_006.txt AC 3 ms 256 KB
1_007.txt AC 3 ms 256 KB
1_008.txt AC 3 ms 256 KB
1_009.txt AC 3 ms 256 KB
1_010.txt AC 3 ms 256 KB
1_011.txt AC 3 ms 256 KB
1_012.txt AC 3 ms 256 KB
1_013.txt AC 3 ms 256 KB
1_014.txt AC 3 ms 256 KB