제출 #1341286

#제출 시각아이디문제언어결과실행 시간메모리
1341286marzuq01Hack (APIO25_hack)C++20
0 / 100
21 ms456 KiB
#include "hack.h"
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define nl '\n'
#define debun(x) cout << #x << ": " << x << "\n";
#define debug(x) cout << #x << ": " << x << " ";

const int mod = 1e9+7;
const int MOD = 998244353;

string yes = "YES";
string no = "NO";

// CODING SETTING :O

void usaco(string name) {
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
void fastIO() {
	ios::sync_with_stdio(0);
	cin.tie(0);
}
// WRONG ANSWER ON TEST 2: ?_?

void inputer() {
	// take the input ONLY:

}

void outputer() {
	//take the input
	//output inputs...
	//solve();


}

void tracker(int test_case, int wanted) {
	if (wanted != test_case) inputer();
	else outputer();
}

// GENERAL SHORTCUTS AND FUNCTIONS :D
template<typename T>
void vprint(const vector<T> &arr) {
	for (auto i : arr) cout << i << " ";
	cout << nl;
}
template <typename T, typename R>
void vpprint(const vector<pair<T,R>> &arr) {
    for (auto i: arr) cout << "{" << i.first << "," << i.second << "} ";
    cout << "\n";
}

template<typename T>
T expo(T a, T b,T m = mod) {
	if (b == 0) return 1;
	else if (b == 1) return a;
	if (b % 2 == 0) return expo(a*a % m,b/2) % m;
	else return (a*expo(a*a % m, b/2) % m) % m;
}

template<typename T>
T gcd(T a, T b) {
	if (a == 0) return b;
	else return gcd(b%a,a);
}
// ============< DONT TOUCH CODES ABOVE >=============
int NNN = 2000000;
int isprime[2000000];
vector<int> prime;
void thanos() {
    for (int i = 0;i < NNN;i++) isprime[i] = 1;
    isprime[0] = isprime[1] = 0;
    for (int j = 4; j < NNN;j+=2) isprime[j] = 0;
    for (int i = 3;i*i < NNN;i+=2) {
        for (int j = i*i; j < NNN;j += i) isprime[j] = 0;
    }
    prime.pb(2);
    for (int i = 3;i < NNN;i+=2) if(isprime[i]) prime.pb(i);
}

// ============< DONT also TOUCH CODES ABOVE >=============

void init() {
    //thanos();
}


int hack(){
    lint k = 200000000ll;
    lint ans = collisions({1ll,k/2ll,k+1ll}); //1e6-2,2*1e6-1,1e6
    while(ans == 0) {
        k-=6ll;
        //1e6-5,2*1e6-4,1e6-3 = k/2 - 1,k,k/2 + 1
        //1e6-4,1e6-4,1e6-4 = k/2,k/2,k/2
        //2e6-8 = k
        ans = collisions({1ll,k/2ll,k+1ll});
    }
    set<lint> divisor;
    for (lint d = 1;d*d <= k;d++) {
        if ((k/2ll-1ll) % d == 0) {
            divisor.insert(d);divisor.insert((k/2ll - 1ll)/d);
        }
        if ((k/2 + 1) % d == 0) {
            divisor.insert(d);divisor.insert((k/2ll + 1ll)/d);
        }
        if ((2ll*k) % d == 0) {divisor.insert(d);divisor.insert((2ll*k)/d);}
    }
    for (auto i: divisor) {
        if (i == 1) continue;
        int nowans = collisions({i,2ll*i});
        if (nowans) return i;
    }

}

컴파일 시 표준 에러 (stderr) 메시지

hack.cpp: In function 'void usaco(std::string)':
hack.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hack.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hack.cpp: In function 'int hack()':
hack.cpp:121:1: warning: control reaches end of non-void function [-Wreturn-type]
  121 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...