제출 #994610

#제출 시각아이디문제언어결과실행 시간메모리
994610salmonPortal (BOI24_portal)C++14
1 / 100
25 ms2504 KiB
#include <bits/stdc++.h> using namespace std; int N; long long int x,y; long long int b,d; long long int b1,d1; long long int h1,h2; bool flag = true; bool floog = true; vector<pair<long long int,long long int>> v; int main(){ long long int num = 0; long long int fum = 0; long long int gom = 0; scanf(" %d",&N); scanf(" %lld",&x); scanf(" %lld",&y); for(int i = 0; i < N - 1; i++){ scanf(" %lld",&h1); scanf(" %lld",&h2); h1 -= x; h2 -= y; if(h1 == 0 && h2 == 0) continue; flag &= (h1==0); floog &= (h2==0); if(h1!=0){ b = h1; d = h2; d *= (b)/abs(b); b = abs(b); } if(h2!=0){ b1 = h1; d1 = h2; b1 *= (d1)/abs(d1); d1 = abs(d1); } v.push_back({h1,h2}); } if(flag || floog){ printf("%d",-1); return 0; } for(pair<long long int,long long int> ii : v){ h1 = ii.first; h2 = ii.second; if(ii.first != 0){ h2 *= (h1)/abs(h1); h1 = abs(h1); long long int c = __gcd(h1,b); num = __gcd(num, h2 * b / c - d * h1 / c ); //printf("%d %d\n",ii.first, h2 * b / c - d * h1 / c ); } else{ num = __gcd(num, h2); } if(ii.second != 0){ h1 *= (h2)/abs(h2); h2 = abs(h2); long long int c = __gcd(h2,d1); fum = __gcd(fum, h1); gom = __gcd(gom, h1 * d1 / c - b1 * h2 / c ); } else{ gom = __gcd(gom,fum); } } fum = abs(fum); num = abs(num); gom = abs(gom); if(fum == 0 || num == 0) printf("%d",-1); else{ printf("%lld",abs(num * gom) / fum); } }

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

Main.cpp: In function 'int main()':
Main.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf(" %d",&N);
      |  ~~~~~^~~~~~~~~~
Main.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf(" %lld",&x);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf(" %lld",&y);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf(" %lld",&h1);
      |   ~~~~~^~~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf(" %lld",&h2);
      |   ~~~~~^~~~~~~~~~~~~
#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...