Submission #321456

#TimeUsernameProblemLanguageResultExecution timeMemory
321456ronnithLutrija (COCI19_lutrija)C++14
70 / 70
195 ms640 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #warning Check Integer OverFlow #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define FORd(i,a,b) for(int i=a;i>=b;i--) #define trav(a,b) for(auto a:b) #define sz(a) a.size() #define maxs(a,b) if(b>a)a=b #define mins(a,b) if(b<a)a=b #ifdef LOCAL #define dbg(x) cerr<<"["<<#x<<":"<<x<<"] " #define dbg2(a,b) dbg(a);dbg(b) #define dbg3(a,b,c) dbg2(a,b);dbg(c) #define dln cerr << ln #else #define dbg(x) 0 #define dbg2(a,b) 0 #define dbg3(a,b,c) 0 #define dln 0 #endif #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (((a)/(__gcd(a,b))) * b) #define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln; #define all(a) (a).begin(), (a).end() #define vi vector<int> #define v vector #define p pair #define pii p<int,int> #define pb push_back #define mk make_pair #define f first #define s second #define ln "\n" typedef long double ld; using namespace std; using namespace __gnu_pbds; ll modF=1e9+7; template<class T> using iset = tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /*INPUT 13 11 37 11 2 17 */ bool isPrime(ll pr) { if(pr <= 1)return false; for(ll i = 2;i * i <= pr;i ++) { if(pr % i == 0)return false; } return true; } ll twin(ll a) { if(isPrime(a + 2))return a + 2; else if(isPrime(a - 2)) return a - 2; else return -1; } void solve(){ ll a,b; cin >> a >> b; ll ta = twin(a); ll tb = twin(b); if(ta != -1 and b == 2) { int len = 0; if(a > ta)len = 2; else len = 3; cout << len << '\n'; if(a > ta) { cout << a << " " << 2 << '\n'; } else { cout << a << " " << ta << " 2\n"; } return; } else if(a == 2 and tb != -1) { int len = 0; if(b > tb)len = 2; else len = 3; cout << len << '\n'; if(b > tb) { cout << 2 << " " << b << '\n'; } else { cout << 2 << " " << tb << " " << b << '\n'; } return; } else if(ta == -1 or tb == -1) { cout << -1 << '\n'; return; } // dbg2(ta,tb); int len = 0; if(a > ta)len += 2; else len += 3; if(b > tb) len += 1; else len += 2; cout << len << '\n'; if(a > ta) { cout << a << " 2 "; } else { cout << a << " " << ta << " 2 "; } if(b > tb) { cout << b << '\n'; } else { cout << tb << " " << b << '\n'; } } int main(){ ios::sync_with_stdio(0);cin.tie(0); int t = 1; // cin >> t; while(t --){ solve(); } }

Compilation message (stderr)

lutrija.cpp:4:2: warning: #warning Check Integer OverFlow [-Wcpp]
    4 | #warning Check Integer OverFlow
      |  ^~~~~~~
#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...