답안 #991448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991448 2024-06-02T09:22:08 Z Andrey Portal (BOI24_portal) C++14
11 / 100
26 ms 4220 KB
#include<bits/stdc++.h>
using namespace std;

long long gcd(long long a, long long b) {
    if(b < 0) {
        b = abs(b);
    }
    if(a < 0) {
        a = abs(a);
    }
    if(b == 0) {
        return a;
    }
    return gcd(b,a%b);
}

long long lcm(long long a, long long b) {
    a = abs(a);
    b = abs(b);
    return (a/gcd(a,b))*b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,a,b,ans = 0,x = 0;
    cin >> n;
    vector<pair<long long,long long>> haha(n);
    for(long long i = 0; i < n; i++) {
        cin >> a >> b;
        haha[i] = {a,b};
    }
    vector<pair<long long,long long>> yay(0);
    for(long long i = 1; i < n; i++) {
        yay.push_back({haha[i].first-haha[i-1].first,haha[i].second-haha[i-1].second});
    }
    for(long long i = 1; i < yay.size(); i++) {
        x = gcd(x,yay[i].second);
        int j = 0;
        if(yay[i].second == 0) {
            ans = gcd(ans,yay[i].first);
        }
        else if(yay[j].second == 0) {
            ans = gcd(ans,yay[j].first);
        }
        else {
            long long a = yay[i].first,b = -yay[i].second,c = yay[j].first,d = -yay[j].second;
            ans = gcd(ans,a*(lcm(b,d)/b)-c*(lcm(b,d)/d));
        }
    }
    if(ans*x == 0) {
        cout << -1;
    }
    else {
        cout << abs(ans*x);
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:39:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(long long i = 1; i < yay.size(); i++) {
      |                          ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 0 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 19 ms 4208 KB Output is correct
3 Correct 20 ms 4056 KB Output is correct
4 Correct 22 ms 4056 KB Output is correct
5 Correct 21 ms 4056 KB Output is correct
6 Correct 20 ms 4056 KB Output is correct
7 Correct 14 ms 4056 KB Output is correct
8 Correct 14 ms 4220 KB Output is correct
9 Correct 15 ms 4052 KB Output is correct
10 Correct 23 ms 4056 KB Output is correct
11 Correct 15 ms 4052 KB Output is correct
12 Correct 16 ms 4056 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 23 ms 4192 KB Output is correct
15 Correct 24 ms 4056 KB Output is correct
16 Correct 21 ms 4056 KB Output is correct
17 Correct 22 ms 4056 KB Output is correct
18 Correct 26 ms 4208 KB Output is correct
19 Correct 21 ms 4056 KB Output is correct
20 Correct 20 ms 4216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 0 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 0 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -