제출 #704757

#제출 시각아이디문제언어결과실행 시간메모리
704757becaidoLutrija (COCI19_lutrija)C++17
42 / 70
447 ms320 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second ll A, B; bool is_prime(ll x) { if (x <= 1) return 0; FOR (i, 2, sqrt(x)) if (x % i == 0) return 0; return 1; } void solve() { cin >> A >> B; if (is_prime(abs(A - B))) { cout << "2\n"; cout << A << ' ' << B << '\n'; return; } vector<ll> ans; ans.pb(A); if (A != 2) { bool f = 0; for (ll x : {A - 2, A, A + 2}) if (is_prime(x) && is_prime(abs(x - 2))) { if (x != A) ans.pb(x); f = 1; break; } if (!f) { cout << "-1\n"; return; } } if (A != 2 && B != 2) ans.pb(2); if (B != 2) { bool f = 0; for (ll x : {B - 2, B, B + 2}) if (is_prime(x) && is_prime(abs(x - 2))) { if (x != B) ans.pb(x); f = 1; break; } if (!f) { cout << "-1\n"; return; } } ans.pb(B); cout << ans.size() << '\n'; for (int x : ans) cout << x << ' '; cout << '\n'; } int main() { Waimai; solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...