Submission #1327957

#TimeUsernameProblemLanguageResultExecution timeMemory
1327957idonoamHack (APIO25_hack)C++20
0 / 100
11 ms1204 KiB
#include "hack.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


ll isbet(ll a, ll b)
{
    ll c = (ll)sqrt(b - a);
    vector<ll> vec;
    for (ll i = 1; i <= c; i++)
    {
        vec.push_back(i);
    }
    for (ll i = a + c; i <= b; i += c)
    {
        vec.push_back(i);
    }
    vec.push_back(b+1);
    return collisions(vec);
}
int hack()
{
    ll mx = 1e9;
    ll mn = 1;
    while (mx > mn + 7)
    {
        ll c = (mx + mn) / 2;
        if (isbet(mn,c))
        {
            mx =c;
        }
        else
        {
            mn = c + 1;
        }
    }
    for (ll i = mn; i < mx; i+=2)
        if (collisions({1, 1 + i * (i + 1)}))
        {
            if (collisions({1, 1 + i}))
                return i;
            return i + 1;
        }
    return mx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...