제출 #991401

#제출 시각아이디문제언어결과실행 시간메모리
991401AndreyPortal (BOI24_portal)C++14
29 / 100
467 ms1048576 KiB
#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 = 0; i < n; i++) { for(long long j = i+1; j < n; j++) { yay.push_back({haha[i].first-haha[j].first,haha[i].second-haha[j].second}); } } for(long long i = 0; i < yay.size(); i++) { x = gcd(x,yay[i].second); int j = i+1; 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; }

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

Main.cpp: In function 'int main()':
Main.cpp:41: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]
   41 |     for(long long i = 0; i < yay.size(); i++) {
      |                          ~~^~~~~~~~~~~~
#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...