ARC 062 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
- 問題
C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
- 解法
回目に見たときの得票数をとする。回目にテレビを見た時、得票数の比がなら、二人の得票数はあるに対して、になっており、さらに、となっている。このようなで最小なものはで求められる。
- 感想
最初はコメントアウトしてあるやつでやったらWAになった。理由がわからない。
「得票数の比がなら、二人の得票数はあるに対して、になっており」に気がつくのがポイントかなあと思います。
#include <iostream> #include <string> #include <algorithm> #include <cstdio> #include <vector> #include <queue> #include <set> #include <numeric> #include <cmath> using namespace std; typedef long long int ll; #define all(x) x.begin(),x.end() const ll mod = 1e9+7; const ll INF = 1e9; const ll MAXN = 1e9; int main() { int n; cin >> n; vector<ll> a(n),t(n); for(int i = 0; i < n; i++){ cin >> t[i] >> a[i]; } ll T = 1,A=1; for(int i = 0; i < n; i++){ //ll co = max(ceil((double)T/t[i]),ceil((double)A/a[i])); これでWAになる理由が分からない... ll x = T/t[i]; ll y = A/a[i]; if(T%t[i] != 0) x++; if(A%a[i] != 0) y++; ll co = max(x,y); T = co * t[i]; A = co * a[i]; } cout << T+A << endl; return 0; }