| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1341254 | marzuq01 | Hack (APIO25_hack) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include "hack.h"
#include <vector>
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int hack(){
lint k = 500000;
while(k) {
auto ans = collisions({k,2*k});
if(ans == 1) break;
k--;
}
vector<lint> divisor;
for (int i = 2; i*i<=k;i++) {
if (k % i == 0) {divisor.pb(i);divisor.pb(k/i);}
}
sort(divisor.begin(),divisor.end());
//for (auto i: divisor) cout << i << " ";
//cout << "\n";
for (auto i: divisor) {
lint now = collisions({i,2*i});
if (now == 1) return i;
}
return k;
}
컴파일 시 표준 에러 (stderr) 메시지
hack.cpp: In function 'int hack()':
hack.cpp:7:5: error: 'lint' was not declared in this scope; did you mean 'uint'?
7 | lint k = 500000;
| ^~~~
| uint
hack.cpp:8:11: error: 'k' was not declared in this scope
8 | while(k) {
| ^
hack.cpp:9:30: error: could not convert '{k, <expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<long long int>'
9 | auto ans = collisions({k,2*k});
| ~~~~~~~~~~^~~~~~~~~
| |
| <brace-enclosed initializer list>
hack.cpp:13:16: error: template argument 2 is invalid
13 | vector<lint> divisor;
| ^
hack.cpp:14:26: error: 'k' was not declared in this scope
14 | for (int i = 2; i*i<=k;i++) {
| ^
hack.cpp:4:12: error: request for member 'push_back' in 'divisor', which is of non-class type 'int'
4 | #define pb push_back
| ^~~~~~~~~
hack.cpp:15:34: note: in expansion of macro 'pb'
15 | if (k % i == 0) {divisor.pb(i);divisor.pb(k/i);}
| ^~
hack.cpp:4:12: error: request for member 'push_back' in 'divisor', which is of non-class type 'int'
4 | #define pb push_back
| ^~~~~~~~~
hack.cpp:15:48: note: in expansion of macro 'pb'
15 | if (k % i == 0) {divisor.pb(i);divisor.pb(k/i);}
| ^~
hack.cpp:17:18: error: request for member 'begin' in 'divisor', which is of non-class type 'int'
17 | sort(divisor.begin(),divisor.end());
| ^~~~~
hack.cpp:17:34: error: request for member 'end' in 'divisor', which is of non-class type 'int'
17 | sort(divisor.begin(),divisor.end());
| ^~~
hack.cpp:20:18: error: 'begin' was not declared in this scope
20 | for (auto i: divisor) {
| ^~~~~~~
hack.cpp:20:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166,
from hack.cpp:3:
/usr/include/c++/13/valarray:1238:5: note: 'std::begin'
1238 | begin(const valarray<_Tp>& __va) noexcept
| ^~~~~
In file included from /usr/include/c++/13/bits/ranges_util.h:34,
from /usr/include/c++/13/tuple:44,
from /usr/include/c++/13/bits/uses_allocator_args.h:38,
from /usr/include/c++/13/bits/memory_resource.h:41,
from /usr/include/c++/13/vector:80,
from hack.h:1,
from hack.cpp:1:
/usr/include/c++/13/bits/ranges_base.h:489:44: note: 'std::ranges::__cust::begin'
489 | inline constexpr __cust_access::_Begin begin{};
| ^~~~~
In file included from /usr/include/c++/13/filesystem:50,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200:
/usr/include/c++/13/bits/fs_dir.h:607:3: note: 'std::filesystem::__cxx11::begin'
607 | begin(recursive_directory_iterator __iter) noexcept
| ^~~~~
In file included from /usr/include/c++/13/bits/stl_iterator_base_types.h:71,
from /usr/include/c++/13/bits/stl_algobase.h:65,
from /usr/include/c++/13/vector:62:
/usr/include/c++/13/bits/iterator_concepts.h:984:10: note: 'std::ranges::__cust_access::begin'
984 | void begin(const auto&) = delete;
| ^~~~~
hack.cpp:20:18: error: 'end' was not declared in this scope
20 | for (auto i: divisor) {
| ^~~~~~~
hack.cpp:20:18: note: suggested alternatives:
/usr/include/c++/13/valarray:1265:5: note: 'std::end'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/13/bits/ranges_base.h:490:42: note: 'std::ranges::__cust::end'
490 | inline constexpr __cust_access::_End end{};
| ^~~
/usr/include/c++/13/bits/fs_dir.h:612:3: note: 'std::filesystem::__cxx11::end'
612 | end(recursive_directory_iterator) noexcept
| ^~~
/usr/include/c++/13/bits/ranges_base.h:137:10: note: 'std::ranges::__cust_access::end'
137 | void end(const auto&) = delete;
| ^~~
hack.cpp:21:13: error: expected ';' before 'now'
21 | lint now = collisions({i,2*i});
| ^~~~
| ;
hack.cpp:21:38: error: expected primary-expression before ')' token
21 | lint now = collisions({i,2*i});
| ^
hack.cpp:22:13: error: 'now' was not declared in this scope; did you mean 'pow'?
22 | if (now == 1) return i;
| ^~~
| pow
hack.cpp:24:12: error: 'k' was not declared in this scope
24 | return k;
| ^