이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
const int nmax=64;
long long req[nmax];
map<long long,long long> seen[nmax];
long long rec(int bit,long long high)
{
if(high<0)return 0;
if(bit==-1)return 1;
high=min(high,req[bit]);
if(seen[bit].count(high))return seen[bit][high];
long long ret=0;
//0
ret=ret+rec(bit-1,high);
//1
ret=ret+rec(bit-1,high-(1LL<<bit));
seen[bit][high]=ret;
return ret;
}
long long count_tastiness(long long x, std::vector<long long> a) {
long long sum=0;
for(int i=0;i<60;i++)
{
if(i<a.size())sum=sum+(1LL<<i)*a[i];
req[i]=sum/x;
seen[i]={};
}
return rec(59,req[59]);
}
/*
int main() {
int q;
assert(scanf("%d", &q) == 1);
vector<int> k(q);
vector<long long> x(q);
vector<vector<long long>> a(q);
vector<long long> results(q);
for (int t = 0; t < q; t++) {
assert(scanf("%d%lld", &k[t], &x[t]) == 2);
a[t] = vector<long long>(k[t]);
for (int i = 0; i < k[t]; i++) {
assert(scanf("%lld", &a[t][i]) == 1);
}
}
fclose(stdin);
for (int t = 0; t < q; t++) {
results[t] = count_tastiness(x[t], a[t]);
}
for (int t = 0; t < q; t++) {
printf("%lld\n", results[t]);
}
fclose(stdout);
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if(i<a.size())sum=sum+(1LL<<i)*a[i];
| ~^~~~~~~~~
# | 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... |