Submission #485952

# Submission time Handle Problem Language Result Execution time Memory
485952 2021-11-09T19:55:11 Z tato Lutrija (COCI19_lutrija) C++14
0 / 70
0 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool check(ll a)
{
	ll x=sqrt(a);
	
	for(ll k=2; k<=x; k++)
		if(a%k==0)
			return false;
			
			return true;
	
	
	
}

int main()
{
	ll  a,b;
	
	cin>>a>>b;
	
	if(a==2 or b==2)
		{
			if(check(a+b))
			{cout<<3<<'\n';
			cout<<a<<' '<<a+b<<' '<<b;
			
			return 0;
				
			}
			
		}
	
	if(abs(a-b)==2)
		{
			cout<<2<<'\n';
			cout<<a<<' '<<b;
			return 0;
		}
	if(a==b)
	{
		if(check(a+2))
		{
			cout<<3<<'\n';
		cout<<a<<' '<<a+2<<' '<<b;
		return 0;
		}
		
	}
	if(abs(a-b)>65 or abs(a-b)==1)
		{
			cout<<-1;
			return 0;
		}
	vector <ll> v;
	for(ll i=min(a,b); i<=b; i+=2)
		{
			if(check(i))
				{
					cout<<-1;
					return 0;
				}
			else
				v.push_back(i);
		}
	cout<<v.size()<<'\n';
	
	for(int k=1; k<v.size(); k++)
		cout<<v[k]<<' ';
	
	return 0;
}

Compilation message

lutrija.cpp: In function 'bool check(long long int)':
lutrija.cpp:10:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   10 |   if(a%k==0)
      |   ^~
lutrija.cpp:13:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   13 |    return true;
      |    ^~~~~~
lutrija.cpp: In function 'int main()':
lutrija.cpp:71:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |  for(int k=1; k<v.size(); k++)
      |               ~^~~~~~~~~
# 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 Correct 0 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 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 -
# 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 -