Submission #491262

#TimeUsernameProblemLanguageResultExecution timeMemory
491262ktkeremLutrija (COCI19_lutrija)C++17
70 / 70
151 ms300 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; ll _i=0; #define ffn(x) _i=x #define llll pair<ll , ll> #define stitr set<llll>::iterator #define fora(y,x) for(ll y=_i;x>y;y++) #define pb push_back #define pf push_front #define debu cout << "hello\n" #define fi first #define sec second const ll limit = 1e9+7; const ll ous=1e5 + 5; const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1}; ll pf(ll x){ ll y = sqrt(x); if(x == 1){ return 0; } for(ll i = 2;y >= i;i++){ if(x % i == 0){ return 0; } } return 1; } void solve(){ ll l , r; cin >> l >> r; if(l!=2 && r!=2){ vector<ll> ans; if(abs(r-l) == 2){ cout <<"2\n"<< l << " " << r; return; } else{ ans.pb(l); if(pf(l-2)){ // do nothing } else if(pf(l + 2)){ ans.pb(l+2); } else{ cout << -1 << "\n"; return; } ans.pb(2); if(pf(r-2)){ // do nothing } else if(pf(r + 2)){ ans.pb(r+2); } else{ cout << -1 << "\n"; return; } ans.pb(r); cout << ans.size() << "\n"; fora(i,ans.size()){ cout << ans[i] << " "; } } } else{ if(l != 2){ ll s= l-2; if(pf(s)){ cout << 2 << "\n" << l << " " << r<< "\n"; } else if(pf(s) && pf(s-2)){ cout << 3 << "\n" << l << " " << s << " " << r << "\n"; } else if(pf(l+2)){ cout << 3 << "\n" << l <<" "<<l+2 << " " << r<< "\n"; } else{ cout << -1 << "\n"; return; } } else{ ll o = r-2; if(pf(o)){ cout << "2\n" << l << " " << r << "\n"; } else if(pf(o) && pf(o-2)){ cout << 3 << "\n" << l << " " << o << " " << r<< "\n"; } else if(pf(r+2)){ cout << 3 << "\n" << l <<" "<< r+2 << " " << r<< "\n"; } else{ cout << "-1\n"; return; } } } return; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); ll t=1; //cin >> t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

lutrija.cpp: In function 'void solve()':
lutrija.cpp:9:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
    9 | #define fora(y,x) for(ll y=_i;x>y;y++)
......
   64 |             fora(i,ans.size()){
      |                                 
lutrija.cpp:64:13: note: in expansion of macro 'fora'
   64 |             fora(i,ans.size()){
      |             ^~~~
#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...