제출 #784481

#제출 시각아이디문제언어결과실행 시간메모리
784481makanhulia이상한 기계 (APIO19_strange_device)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long // #define i128 long long #define i128 __int128_t; int n, a, b; vector<pair<int, int>> sg; const int maks = 1e18; i128 gcd(i128 a, i128 b) { if (b == 0) return a; return gcd(b, a%b); } signed main() { i128 temp; // int temp; int size; cin >> n >> a >> b; temp = (a/gcd(a,b+1))*b; // if ((b+1 % a) == 0) size = b; if (temp > maks) size = maks; else size = temp; int l, r; for (int i = 0; i < n; i++) { cin >> l >> r; // cout << l << " " << r << endl; if (r - l + 1 >= size) { cout << size << endl; return 0; } else if (l%size > r%size) { sg.push_back({l%size, 1}); sg.push_back({size-1, 2}); sg.push_back({0, 1}); sg.push_back({r%size, 2}); } else { sg.push_back({l%size, 1}); sg.push_back({r%size, 2}); } sort(sg.begin(), sg.end()); } int cnt = 0, l2; vector<pair<int, int>> ans; for (int i = 0; i < sg.size(); i++) { // cout << sg[i].first << " " << sg[i].second << endl; if (sg[i].second == 1) { if (cnt == 0) l2 = sg[i].first; cnt++; } else cnt--; if (cnt == 0) ans.push_back({l2, sg[i].first}); } int res = 0; for (auto i: ans) { // cout << i.first << " " << i.second << endl; res += (i.second - i.first + 1); } cout << res << endl; }

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

strange_device.cpp:6:14: error: declaration does not declare anything [-fpermissive]
    6 | #define i128 __int128_t;
      |              ^~~~~~~~~~
strange_device.cpp:12:1: note: in expansion of macro 'i128'
   12 | i128 gcd(i128 a, i128 b) {
      | ^~~~
strange_device.cpp:6:24: error: expected ')' before ';' token
    6 | #define i128 __int128_t;
      |                        ^
strange_device.cpp:12:10: note: in expansion of macro 'i128'
   12 | i128 gcd(i128 a, i128 b) {
      |          ^~~~
strange_device.cpp:12:9: note: to match this '('
   12 | i128 gcd(i128 a, i128 b) {
      |         ^
strange_device.cpp:6:24: error: expected constructor, destructor, or type conversion before ';' token
    6 | #define i128 __int128_t;
      |                        ^
strange_device.cpp:12:10: note: in expansion of macro 'i128'
   12 | i128 gcd(i128 a, i128 b) {
      |          ^~~~
strange_device.cpp:12:15: error: 'a' does not name a type
   12 | i128 gcd(i128 a, i128 b) {
      |               ^
strange_device.cpp:12:23: error: 'b' does not name a type
   12 | i128 gcd(i128 a, i128 b) {
      |                       ^
strange_device.cpp: In function 'int main()':
strange_device.cpp:6:14: error: declaration does not declare anything [-fpermissive]
    6 | #define i128 __int128_t;
      |              ^~~~~~~~~~
strange_device.cpp:18:3: note: in expansion of macro 'i128'
   18 |   i128 temp;
      |   ^~~~
strange_device.cpp:18:8: error: 'temp' was not declared in this scope
   18 |   i128 temp;
      |        ^~~~
strange_device.cpp:48:21: 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]
   48 |   for (int i = 0; i < sg.size(); i++) {
      |                   ~~^~~~~~~~~~~