zoukankan      html  css  js  c++  java
  • Codeforces 460D Little Victor and Set(看题解)

    Little Victor and Set

    其他都很好求, 只有k == 3的时候很难受。。

    我们找到第一个不大于l的 t, 答案为 l, 3 * t, (3 * t) ^ l

    感觉好像是对的, 感觉又不会证明, 啊, 我好菜啊。

    #include<bits/stdc++.h>
    #define LL long long
    #define fi first
    #define se second
    #define mk make_pair
    #define PLL pair<LL, LL>
    #define PLI pair<LL, int>
    #define PII pair<int, int>
    #define SZ(x) ((int)x.size())
    #define ull unsigned long long
    
    using namespace std;
    
    const int N = 5e5 + 7;
    const int inf = 0x3f3f3f3f;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const int mod = 1e9 + 7;
    const double eps = 1e-8;
    const double PI = acos(-1);
    
    LL l, r, k;
    
    void print(LL x, int cnt) {
        if(!cnt) return;
        print(x / 2, cnt - 1);
        printf("%d", x & 1);
    }
    
    int main() {
        scanf("%lld%lld%lld", &l, &r, &k);
        LL n = r - l + 1;
        if(k == 1) {
            printf("%lld
    ", l);
            puts("1");
            printf("%lld
    ", l);
        } else if(k == 2) {
            if(n == 2) {
                if(l < (l ^ r)) {
                    printf("%lld
    ", l);
                    puts("1");
                    printf("%lld
    ", l);
                } else {
                    printf("%lld
    ", l ^ r);
                    puts("2");
                    printf("%lld %lld
    ", l, r);
                }
            } else {
                if(l & 1) {
                    printf("%lld
    ", (l + 1) ^ (l + 2));
                    puts("2");
                    printf("%lld %lld
    ", (l + 1), (l + 2));
                } else {
                    printf("%lld
    ", l ^ (l + 1));
                    puts("2");
                    printf("%lld %lld
    ", l, (l + 1));
                }
            }
        } else if(k == 3) {
            LL t = 1;
            while(t * 2 <= l) t *= 2;
            if(t * 3 <= r) {
                puts("0");
                puts("3");
                printf("%lld %lld %lld
    ", l, 3 * t, (3 * t) ^ l);
            } else {
                puts("1");
                puts("2");
                if(l & 1) printf("%lld %lld
    ", l + 1, l + 2);
                else printf("%lld %lld
    ", l, l + 1);
            }
        } else {
            if(l & 1) {
                if(n >= 5) {
                    puts("0");
                    puts("4");
                    for(LL i = l + 1; i < l + 5; i++)
                        printf("%lld ", i);
                    puts("");
                } else {
                    for(int S = 1; S < (1 << n); S++) {
                        vector<LL> vc;
                        LL val = 0;
                        for(int i = 0; i < n; i++)
                            if(S >> i & 1) val ^= l + i, vc.push_back(l + i);
                        if(!val) {
                            puts("0");
                            printf("%d
    ", SZ(vc));
                            for(auto& t : vc) printf("%lld ", t);
                            puts("");
                            return 0;
                        }
                    }
                    puts("1");
                    puts("2");
                    printf("%lld %lld
    ", l + 1, l + 2);
                }
            } else {
                puts("0");
                puts("4");
                for(LL i = l; i < l + 4; i++)
                    printf("%lld ", i);
                puts("");
            }
        }
        return 0;
    }
    
    /*
    */
  • 相关阅读:
    JavaScript之DOM
    MapReduce多种join实现实例分析(一)
    JavaScript的文档对象模型DOM
    JavaScript原生实现观察者模式
    Idea环境下git 图形化操作
    一分钟教你如何实现唯美的文字描边
    Redis集群
    JAVA线程池的实际运用
    Java 线程池(ThreadPoolExecutor)原理解析
    win7开始菜单路径
  • 原文地址:https://www.cnblogs.com/CJLHY/p/10467852.html
Copyright © 2011-2022 走看看