Submission #491253

# Submission time Handle Problem Language Result Execution time Memory
491253 2021-12-01T07:31:42 Z Nimbostratus Lutrija (COCI19_lutrija) C++17
0 / 70
1 ms 272 KB
#include "bits/stdc++.h"
#define endl '\n'
#define int long long
const int maxn = 2e5 + 5;
const int inf = 2e9;
const int mod = 1e9 + 7;
using namespace std;
using lint = long long;
using pii = pair<int,int>;

lint a, b;
bool rev;
vector<lint> ans;

bool prime(lint x) {
	if(x <= 1)
		return false;
	for(lint i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	return true;
}

signed main() {
	#ifdef Local
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> a >> b;
	if(a > b) {
		swap(a, b);
		rev = true;
	}
	ans.push_back(a);
	if(a == 2) {
		if(prime(b + 2))
			ans.push_back(b + 2);
		else if(prime(b - 2) && prime(b - 4))
			ans.push_back(b - 2);
		else if(!prime(b - 2)) {
			cout << -1 << endl;
			return 0;
		}
	}
	else if(b - a != 2) {
		cout << -1 << endl;
		return 0;
	}
	ans.push_back(b);
	if(rev)
		reverse(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for(lint i = 0; i < ans.size() - 1; i++)
		cout << ans[i] << " ";
	cout << ans.back() << endl;

}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:55:20: warning: comparison of integer expressions of different signedness: 'lint' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(lint i = 0; i < ans.size() - 1; i++)
      |                  ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -