Submission #1281533

#TimeUsernameProblemLanguageResultExecution timeMemory
1281533testaccountPortal (BOI24_portal)C++20
100 / 100
22 ms580 KiB
#include <bits/stdc++.h>
#define el '\n'
#define FNAME "portal"
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,n) memset(x,(n),sizeof(x))
using namespace std;
const long long MOD = (long long) 1e9+7;
template<class X,class Y> bool minimize(X &a,Y b){ if (a>b) {a=b; return true;} return false;}
template<class X,class Y> bool maximize(X &a,Y b){ if (a<b) {a=b; return true;} return false;}

void setup(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	if (fopen(FNAME".inp","r")){
		freopen(FNAME".inp","r",stdin);
		freopen(FNAME".out","w",stdout);
	}
}

long long a,b,c;

void add(long long x,long long y){
	while (x){
		long long t = a/x;
		a-= x*t;
		b-= y*t;
		swap(a,x);
		swap(b,y);
	}
	c = __gcd(c,y);
	if (c) b%=c;
}

int n;
long long p,q;
vector<pair<long long,long long>> v;

void init(){
	cin>>n>>p>>q;
	for (int i=1;i<n;i++){
		long long x,y;
		cin>>x>>y;
		add(x-p,y-q);
	}
}

void sol(){
	cout<< (a*c==0 ? -1 : llabs(a*c));
}

int main(){
    setup();
    init();
    sol();
}

Compilation message (stderr)

Main.cpp: In function 'void setup()':
Main.cpp:16:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |                 freopen(FNAME".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:17:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |                 freopen(FNAME".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...