Submission #1212294

#TimeUsernameProblemLanguageResultExecution timeMemory
1212294fadak-14Hack (APIO25_hack)C++20
Compilation error
0 ms0 KiB
#include "hack.h"
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define endl '\n'
#define eb emplace_back
#define em emplace
#define pb push_back
#define pf push_front
#define pp pop_back
#define fr first
#define sc second
#define sz size
using namespace std;
const int mx = 1e9;
signed hack() {
    int s = mx / 2 + 1 ;
    int e = mx ;
    int v ,x ;
    vector<int> tp , arr ;
    while(s <= e) {
        int md = s + e >> 1 ;
        tp.clear() ;
        x= (int)sqrt(md - s + 1) ;
        for(int i =1 ; i <= x ; i++) tp.pb(i) ;
        for(int i =1 ;s + i * x <= md; i++) tp.pb(s + i * x) ;
        tp.pb(md + 1) ;
        if(collisions(tp) > 0) e = md - 1 , v = md ;
        else s = md + 1 ;
    }
    x = v ;
    for(int i = 2 ; i * i <= v; i++) {
        if(x % i) continue ;
        arr.pb(i) ;
        while(x % i == 0) x /= i ;
    }
    if(x > 1) arr.pb(x) ;
    for(int : arr) {
        while(v%i == 0 && collisions({1 , v/ i + 1}) > 0) v/=i;
    }
    return v;
}
    

Compilation message (stderr)

hack.cpp: In function 'int hack()':
hack.cpp:29:23: error: could not convert 'tp' from 'vector<int>' to 'vector<long long int>'
   29 |         if(collisions(tp) > 0) e = md - 1 , v = md ;
      |                       ^~
      |                       |
      |                       vector<int>
hack.cpp:39:13: error: expected unqualified-id before ':' token
   39 |     for(int : arr) {
      |             ^
hack.cpp:40:17: error: 'i' was not declared in this scope
   40 |         while(v%i == 0 && collisions({1 , v/ i + 1}) > 0) v/=i;
      |                 ^
hack.cpp:40:37: error: could not convert '{1, <expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<long long int>'
   40 |         while(v%i == 0 && collisions({1 , v/ i + 1}) > 0) v/=i;
      |                           ~~~~~~~~~~^~~~~~~~~~~~~~~~
      |                                     |
      |                                     <brace-enclosed initializer list>