답안 #1089555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089555 2024-09-16T16:25:41 Z sangeraf Lutrija (COCI19_lutrija) C++17
70 / 70
41 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

bool isPrime(long long x){
	if(x==1) return 0;
	for(long long i=2; i*i<=x; i++){
		if(x%i==0) return 0;
	}
	return 1;
}

int main() {
	long long a, b; cin >> a >> b;
	if(max(a-b, b-a) == 2){
		cout << 2 << endl << a << " " << b << endl;
		return 0;
	}
	vector<long long> ans;
	if(a>2){
		if(isPrime(a-2)){
			ans.push_back(a);
		}else if(isPrime(a+2)){
			ans.push_back(a);
			ans.push_back(a+2);
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	ans.push_back(2);
	if(b>2){
		if(isPrime(b-2)){
			ans.push_back(b);
		}else if(isPrime(b+2)){
			ans.push_back(b+2);
			ans.push_back(b);
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i=0; i<ans.size(); i++){
      |               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct