【瞎搞】 Codeforces 460D Little Victor and Set 位运算构造

来源:互联网 发布:淘宝钱柜数码 编辑:程序博客网 时间:2024/05/21 21:01

点击打开链接

L^L==0



L为偶数时

L^(L+1)^(L+2)^(L+3)==0

L^(L+1)==1


#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>#define cler(arr, val)    memset(arr, val, sizeof(arr))typedef long long  LL;const int MAXN = 150100;const int MAXM = 11111;const int INF = 0x3f3f3f3f;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int main(){    LL l,r,k;    cin>>l>>r>>k;    if(k>=4)    {        if((l&1)&&(r-l)>=4)        {            cout<<0<<endl;            cout<<4<<endl;            cout<<l+1<<" "<<l+2<<" "<<l+3<<" "<<l+4<<endl;            return 0;        }        else if(!(l&1))        {            cout<<0<<endl;            cout<<4<<endl;            cout<<l<<" "<<l+1<<" "<<l+2<<" "<<l+3<<endl;            return 0;        }    }    if(k>=3)    {        LL tol=0,tp=l;        while(tp)        {            tp>>=1;            ++tol;        }        tp=(LL)3<<(tol-1);        if(tp<=r)        {            cout<<0<<endl;            cout<<3<<endl;            cout<<tp<<" "<<l<<" "<<(tp^l)<<endl;            return 0;        }    }    if(k>=2)    {        if((l&1) && r-l>=2)        {            cout<<1<<endl;            cout<<2<<endl;            cout<<l+1<<" "<<l+2<<endl;            return 0;        }        else if(!(l&1))        {            cout<<1<<endl;            cout<<2<<endl;            cout<<l<<" "<<l+1<<endl;            return 0;        }        else if((l^r)<l)        {            cout<<(l^r)<<endl;            cout<<2<<endl;            cout<<l<<" "<<r<<endl;            return 0;        }    }    if(k>=1)    {        cout<<l<<endl;        cout<<1<<endl;        cout<<l<<endl;        return 0;    }}


0 0