Codeforces 460d Littel victor and set
来源:互联网 发布:达芬奇14mac怎么改中文 编辑:程序博客网 时间:2024/05/01 08:05
- 题意:给出一个范围[l,r],以及一个数k,让从[l,r]这个区间中选不超过k个数a1, a2, a3…an,使f = a1^a2^a3…^an最小。
- 思路:就是一个找规律的数学题。可以先从两个的入手,然后再从4个的入手,最难得其实是3个数的情况,但是仔细分析不难观察到其规律,代码已经很能说明思路了就不再反复写了。
- 代码:
/************************************************************************* > File Name: 460d.cpp > Author: Mathon > Mail: luoxinchen96@qq.com > Created Time: 2015年09月04日 星期五 14时53分25秒 ************************************************************************/#include <bits/stdc++.h>using namespace std;typedef long long LL;int main(){ LL l, r, k; cin >> l >> r >> k; if(k >= 4) { for(LL i = l; i + 3 <= r; i++) { if(i % 2 == 0) { printf("0\n4\n%I64d %I64d %I64d %I64d\n", i, i + 1, i + 2, i + 3); return 0; } } } if(k >= 3) { LL t = 3; LL x = l; while(x > 0) { x >>= 1; t <<= 1; } t >>= 1; if(t <= r) { printf("0\n3\n%I64d %I64d %I64d\n", t, l^t, l); return 0; } } if(k >= 2) { for(LL i = l; i + 1 <= r; i++) { if(i % 2 == 0) { printf("1\n2\n%I64d %I64d\n", i, i+1); return 0; } } } if(k > 1) { if((l^r) < l) { printf("%I64d\n2\n%I64d %I64d\n", l^r, l, r); return 0; } } printf("%I64d\n1\n%I64d\n", l, l); return 0;}
0 0
- Codeforces 460d Littel victor and set
- Codeforces 460 D. Little Victor and Set
- Codeforces 460D Little Victor and Set(构造)
- codeforces #460D Little Victor and Set 构造
- codeforces 460D Little Victor and Set(构造)
- [Codeforces 460D] Little Victor and Set (构造)
- codeforces 460D Little Victor and Set(构造)
- Codeforces Round #262 (Div. 2) D Little Victor and Set
- 【瞎搞】 Codeforces 460D Little Victor and Set 位运算构造
- CF 262Div2 D Little Victor and Set
- 【Codeforces Round 262 (Div 2)D】【构造】Little Victor and Set 集合最多取k数使得异或值尽可能小
- [Codeforces460D] Little Victor and Set(构造)
- CodeForces - 749D set+二分
- codeforces 675D (STL set)
- Victor and Machine
- 【hdu5419】Victor and Toys
- Victor and Machine
- HDU5421-Victor and String
- 忆昔悟今
- 应用程序的 DIY__(给程序加上新功能)
- 9.3 - 抗战胜利日
- 自我学习
- strcpy,strnpy和strlcpy的区别
- Codeforces 460d Littel victor and set
- usaco Longest Prefix
- 二进制中1的个数
- SQL存储过程+事务 常用实例
- 剑指offer整理归纳(2/2)
- 树莓派折腾日记2-DLNA云服务器的架设
- Web母版制作和母版嵌套
- arduino uno接口部分介绍
- 条款 07 为多态基类声明vitual析构函数