#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c lr; ll INF = 1000000000000000009; vll remove(ll a, ll b){ if(a>b) swap(a, b); auto itr = lr.lower_bound(vll{b+1, 0}); if(itr==lr.begin()) return vll{a, b}; itr--; ll lef = a, ri = b; while((*itr)[1]>=a){ ll now_x = (*itr)[0], now_y = (*itr)[1]; lef = min(lef, now_x), ri = max(ri, now_y); if(itr==lr.begin()){ lr.erase(itr); break; } itr--; lr.erase(vll{now_x, now_y}); } return vll{lef, ri}; } void merge(ll a, ll b){lr.insert(remove(a, b));} vll get(ll a){ auto itr = lr.lower_bound(vll{a+1, a+1}); if(lr.size()==0||itr==lr.begin()) return vll{INF, INF}; itr--; if((*itr)[1]> n; vll prm(10001, 1); prm[0] = prm[1] = 0; for(ll i=2;i<=10000;i++){ if(!prm[i]) continue; for(ll j=i*i;j<=10000;j+=i) prm[j] = 0; } vll p; for(int i=2;i<=10000;i++) if(prm[i]) p.push_back(i); vll g(10001, 0); g[0] = g[1] = 1; for(int i=2;i<=n;i++){ vll t; Merge mg; for(auto e:p) if(i-e>=0) mg.merge(g[i-e], g[i-e]+1); auto itr = mg.lr.begin(); if((*itr)[0]!=0) g[i] = 0; else g[i] = (*itr)[1]; } //for(int i=0;i<10;i++) std::cout << p[i] << " "; //std::cout << '\n'; //for(int i=0;i<=n;i++) std::cout << g[i] << " "; //std::cout << '\n'; std::cout << (g[n]?"Win":"Lose") << '\n'; }