Submission #1339837

#TimeUsernameProblemLanguageResultExecution timeMemory
1339837thesentroHack (APIO25_hack)C++20
25 / 100
81 ms428 KiB
#include "hack.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll x, ll y)
{
    if (y==0)
        return x;
    return gcd(y, x%y);
}
int hack(){
    // std::vector<long long> x = {1, 2, 3};
    // long long a = collisions(x);
    // long long b = collisions({92, 65});
    ll g = 0;
    for (int i=1e6 ; i>502000 ; i--)
    {
        ll val = i;
        ll l = 1e6+1;
        ll r = l+i;
        if (collisions({l, r})==0) continue;
        g = i;
        for (int j=1 ; j<=sqrt(i) ; j++)
        {
            if (i%j==0)
            {
                if (collisions({1000001, 1000001+j})>0)
                    g = gcd(g, j);
                if (collisions({1000001, 1000001+i/j})>0)
                    g = gcd(g, i/j);
            }
        }
        return g;
    }
    for (int i=502000 ; i>500000 ; i--)
    {
        if (collisions({1000001, 1000001+i})>0)
        {
            return i;
        }
    }
    
}

Compilation message (stderr)

hack.cpp: In function 'int hack()':
hack.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...