이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool stgg(long long x)
{
if (x <= 1)
return false;
for (long long i = 2; i * i <= x; ++i)
{
if (x % i == 0)
return false;
}
return true;
}
bool stg(const vector<long long>& v)
{
for (int i = 0; i < v.size() - 1; ++i)
{
if (!stgg(v[i]))
return false;
if (!stgg(abs(v[i + 1] - v[i])))
return false;
}
return true;
}
int main()
{
long long a, b;
scanf("%lld%lld", &a, &b);
if (stg({a, b}))
{
printf("2\n%lld %lld\n", a, b);
return 0;
}
if (stg({a, 2, b}))
{
printf("3\n%lld %lld %lld\n", a, 2, b);
return 0;
}
if (a == 2)
{
if (stg({a, b + 2, b}))
{
printf("3\n%lld %lld %lld\n", a, b + 2, b);
return 0;
}
if (stg({a, b - 2, b}))
{
printf("3\n%lld %lld %lld\n", a, b - 2, b);
return 0;
}
}
if (b == 2)
{
if (stg({a, a + 2, b}))
{
printf("3\n%lld %lld %lld\n", a, a + 2, b);
return 0;
}
if (stg({a, a - 2, b}))
{
printf("3\n%lld %lld %lld\n", a, a - 2, b);
return 0;
}
}
printf("-1\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
lutrija.cpp: In function 'bool stg(const std::vector<long long int>&)':
lutrija.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size() - 1; ++i)
~~^~~~~~~~~~~~~~
lutrija.cpp: In function 'int main()':
lutrija.cpp:39:46: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'int' [-Wformat=]
printf("3\n%lld %lld %lld\n", a, 2, b);
^
lutrija.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &a, &b);
~~~~~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |