이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
using namespace std;
const int mod = 1000000007;
void add(int& a, int b) {
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
}
int mult(int a, int b) {
return a * (ll)b % mod;
}
int bp(int a, int b) {
int res = 1;
while (b > 0) {
if (b & 1) res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
ll count_tastiness(ll x, vector<ll> a) {
int k = a.size();
vector<ll> bounds;
for (int i = 0; i < 20; ++i) {
ll sum = 0;
for (int j = 0; j < min(k, i+1); ++j) {
sum += (1LL<<j) * a[j];
}
bounds.pb(sum / x);
}
int ans = 0;
for (int j = 0; j <= 100000; ++j) {
bool can = true;
for (int e = 0; e < 20; ++e) {
if ((j+1)%(1<<(e+1)) > bounds[e]) {
//if (j == 1) cout << (j+1)%(1<<(e+1)) << " " << bounds[e] << endl;
can = false;
}
}
ans += can;
}
return ans;
}
#ifdef LOCAL
int main(){
freopen("A_input.txt", "r", stdin);
//freopen("A_output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int k;
ll x;
cin >> k >> x;
vector<ll> v(k);
for (auto &x : v) cin >> x;
cout << count_tastiness(x, v) << endl;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |