| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1281721 | quangminh412 | Portal (BOI24_portal) | C++17 | 14 ms | 1208 KiB |
/*
Ben Watson
Quang Minh MasterDDDDD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const string name = "test";
void solve();
signed main()
{
if (fopen((name + ".inp").c_str(), "r"))
{
freopen((name + ".inp").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
return 0;
}
// main program
ll GCD(ll a, ll b) { return (b == 0 ? a : GCD(b, a % b)); }
ll a = 0, b = 0, c = 0;
void euclid(ll x, ll y)
{
while (x)
{
ll t = a / x;
a -= t * x;
b -= t * x;
swap(a, x);
swap(b, y);
}
c = GCD(c, y);
if (c != 0)
b %= c;
}
void solve()
{
int n; cin >> n;
int X[n], Y[n];
for (int i = 0; i < n; i++)
cin >> X[i] >> Y[i];
for (int i = 1; i < n; i++)
euclid(X[i] - X[0], Y[i] - Y[0]);
if (a == 0 || c == 0)
cout << -1 << '\n';
else
cout << abs(a * c) << '\n';
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
