이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#ifdef local
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__)
template <typename H, typename ...T> void qqbx(const char*s, const H &h, T ...args) {
for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
if constexpr (sizeof...(T)) qqbx(++s, args...);
}
#else
#include "biscuits.h"
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define pb emplace_back
using namespace std;
typedef long long ll;
const int N = 2500025;
bool check(ll y, ll x, vector<ll> a) {
int k = a.size();
ll now = 0;
for(int i = 0; i < k; i++) {
now += a[i] << i;
ll m = y & ((1LL<<i+1)-1);
if(now < x * m) return false;
}
return true;
/*
ll sum = 0, yf = 0;
for(int i = 0; i < k; i++) {
sum += a[i] << i;
yf += y & (1LL << i);
if(sum / x < yf) return false;
}
return true;
*/
}
ll count_tastiness(ll x, vector<ll> a) {
int k = a.size();
cerr << x << '\n';
for(int i = 0; i < k; i++) cerr << a[i] << (i+1==k ? '\n' : ' ');
ll sum = 0;
for(int i = 0; i < k; i++) sum += a[i] << i;
ll ans = 0;
for(int y = 0; y <= sum / x; y++) {
if(check(y, x, a)) ++ans, debug(y);
}
debug(ans);
return ans;
}
#ifdef local
signed main() {
count_tastiness(3, {5, 2, 1});
count_tastiness(2, {2, 1, 2});
}
#endif // local
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'bool check(ll, ll, std::vector<long long int>)':
biscuits.cpp:26:28: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
26 | ll m = y & ((1LL<<i+1)-1);
| ~^~
# | 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... |