Submission #1350814

#TimeUsernameProblemLanguageResultExecution timeMemory
1350814AndreyPacking Biscuits (IOI20_biscuits)C++20
Compilation error
0 ms0 KiB
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;

long long count_tastiness(long long x, std::vector<long long> a) {
    if(x > 1e6) {
        return 1;
    }
    a.push_back(0);
    vector<long long> ansv(0);
    vector<long long> pv(0);
    vector<long long> sv(0);
    long long ans = 1,p = 0;
    while(p < min(20,(int)a.size()) {
        long long s = 0,y = 1,p1 = a.size();
        for(int i = p; i < a.size(); i++) {
            s+=a[i]*y;
            y*=2;
            if(s/x < y-1) {
                p1 = i+1;
                break;
            }
        }
        ansv.push_back(ans);
        sv.push_back(s);
        pv.push_back(p);
        ans*=(s/x)+1;
        if((1LL << (62LL-p)) >= x-(s%x)) {
            long long r = (x-(s%x))*(1LL << p);
            for(long long i = (long long)ansv.size()-2; i >= 0; i--) {
                if((sv[i]*(1LL << pv[i])-r+x*(1LL << pv[i])) < 0) {
                    break;
                }
                long long d = (sv[i]*(1LL << pv[i])-r+x*(1LL << pv[i]))/(x*(1LL << pv[i]));
                ans+=ansv[i]*d;
                if(sv[i]*(1LL << pv[i])-d*x*(1LL << pv[i]) >= 0) {
                    r-=sv[i]*(1LL << pv[i])-d*x*(1LL << pv[i]);
                }
                else {
                    break;
                }
            }
            if(r == 0) {
                ans++;
            }
        }
        p = p1;
    }
    return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:14:36: error: expected ')' before '{' token
   14 |     while(p < min(20,(int)a.size()) {
      |          ~                         ^~
      |                                    )