제출 #675559

#제출 시각아이디문제언어결과실행 시간메모리
675559VodkaInTheJar비스킷 담기 (IOI20_biscuits)C++14
0 / 100
13 ms724 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define endl '\n' using namespace std; const long double eps = 1e-6; long long count_tastiness(long long x, vector <long long> a) { long double c = 0; long long d = 1; long long ans = 1; int sz = (int)a.size(); for (int i = 0; ; i++) { c /= 2.0; if (i < sz) c += (long double)a[i]; if (c < x - eps && i >= sz) break; if (c < x - eps) { d <<= 1ll; continue; } //cout << c << "wtf" << endl; long long low = 0, high = d-1; while (low < high) { long long mid = (low + high + 1) >> 1ll; long double res = c - (long double)x / (long double)d * (long double)mid; if (res > x + eps || fabs(res - x) < eps) low = mid; else high = mid-1; } ans += low + 1; //cout << d << " " << low << " " << c << endl; d <<= 1ll; } return ans; } /* int main() { long long x, n; cin >> x >> n; vector <long long> a(n); for (int i = 0; i < n; i++) cin >> a[i]; cout << count_tastiness(x, a) << endl; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...