Codeforces 460D 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 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); LL l, r, k; void print(LL x, int cnt) {
if(!cnt) return;
print(x / , cnt - );
printf("%d", x & );
} int main() {
scanf("%lld%lld%lld", &l, &r, &k);
LL n = r - l + ;
if(k == ) {
printf("%lld\n", l);
puts("");
printf("%lld\n", l);
} else if(k == ) {
if(n == ) {
if(l < (l ^ r)) {
printf("%lld\n", l);
puts("");
printf("%lld\n", l);
} else {
printf("%lld\n", l ^ r);
puts("");
printf("%lld %lld\n", l, r);
}
} else {
if(l & ) {
printf("%lld\n", (l + ) ^ (l + ));
puts("");
printf("%lld %lld\n", (l + ), (l + ));
} else {
printf("%lld\n", l ^ (l + ));
puts("");
printf("%lld %lld\n", l, (l + ));
}
}
} else if(k == ) {
LL t = ;
while(t * <= l) t *= ;
if(t * <= r) {
puts("");
puts("");
printf("%lld %lld %lld\n", l, * t, ( * t) ^ l);
} else {
puts("");
puts("");
if(l & ) printf("%lld %lld\n", l + , l + );
else printf("%lld %lld\n", l, l + );
}
} else {
if(l & ) {
if(n >= ) {
puts("");
puts("");
for(LL i = l + ; i < l + ; i++)
printf("%lld ", i);
puts("");
} else {
for(int S = ; S < ( << n); S++) {
vector<LL> vc;
LL val = ;
for(int i = ; i < n; i++)
if(S >> i & ) val ^= l + i, vc.push_back(l + i);
if(!val) {
puts("");
printf("%d\n", SZ(vc));
for(auto& t : vc) printf("%lld ", t);
puts("");
return ;
}
}
puts("");
puts("");
printf("%lld %lld\n", l + , l + );
}
} else {
puts("");
puts("");
for(LL i = l; i < l + ; i++)
printf("%lld ", i);
puts("");
}
}
return ;
} /*
*/
Codeforces 460D Little Victor and Set(看题解)的更多相关文章
- codeforces 460D Little Victor and Set(构造、枚举)
最近的CF几乎都没打,感觉挺水的一个题,不过自己仿佛状态不在,看题解才知道做法. 输入l, r, k (1 ≤ l ≤ r ≤ 1012; 1 ≤ k ≤ min(106, r - l + 1)). ...
- Codeforces 229E Gifts 概率dp (看题解)
Gifts 感觉题解写的就是坨不知道什么东西.. 看得这个题解. #include<bits/stdc++.h> #define LL long long #define LD long ...
- Codeforces 460D Little Victor and Set --分类讨论+构造
题意:从区间[L,R]中选取不多于k个数,使这些数异或和尽量小,输出最小异或和以及选取的那些数. 解法:分类讨论. 设选取k个数. 1. k=4的时候如果区间长度>=4且L是偶数,那么可以构造四 ...
- Codeforces 1155F Delivery Oligopoly dp(看题解)
看别人写的才学会的... 我们考虑刚开始的一个点, 然后我们枚举接上去的一条一条链, dp[mask]表示当前已经加进去点的状态是mask所需的最少边数. 反正就是很麻烦的一道题, 让我自己写我是写不 ...
- Codeforces 460D. Little Victor and Set
D. Little Victor and Set time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- Codeforces 380D Sereja and Cinema (看题解)
Sereja and Cinema 首先我们可以发现除了第一个人, 其他人都会坐在已入坐人的旁边. 难点在于计算方案数.. 我们可以从外往里把确定的人用组合数算上去,然后缩小范围. #include& ...
- Codeforces 442D Adam and Tree dp (看题解)
Adam and Tree 感觉非常巧妙的一题.. 如果对于一个已经建立完成的树, 那么我们可以用dp[ i ]表示染完 i 这棵子树, 并给从fa[ i ] -> i的条边也染色的最少颜色数. ...
- Codeforces 915G Coprime Arrays 莫比乌斯反演 (看题解)
Coprime Arrays 啊,我感觉我更本不会莫比乌斯啊啊啊, 感觉每次都学不会, 我好菜啊. #include<bits/stdc++.h> #define LL long long ...
- Codeforces 1101F Trucks and Cities dp (看题解)
Trucks and Cities 一个很显然的做法就是二分然后对于每个车贪心取check, 这肯定会TLE, 感觉会给人一种贪心去写的误导... 感觉有这个误导之后很难往dp那个方向靠.. dp[ ...
随机推荐
- python学习笔记8--面向对象--属性和方法详解
属性: 公有属性 (属于类,每个类一份) 普通属性 (属于对象,每个对象一份) 私有属性 (属于对象,跟普通属性相似,只是不能通过对象直接访问) 方法:(按作用) 构造方法 析构函数 方法: ...
- 旅行商问题(TSP)、最长路径问题与哈密尔顿回路之间的联系(归约)
一,旅行商问题与H回路的联系(H回路 定义为 哈密尔顿回路) 旅行商问题是希望售货员恰好访问每个城市一次,最终回到起始城市所用的费用最低,也即判断图中是否存在一个费用至多为K的回路.(K相当于图中顶点 ...
- Linux下删除命令 硬盘空间查看... 常用命令
(此命令请慎重使用) 使用rm -rf命令即可. 使用rm -rf 目录名字 命令即可 -r 就是向下递归,不管有多少级目录,一并删除-f 就是直接强行删除,不作任何提示的意思 (警告:不作任何 ...
- 表格重新加载 where 携带上次值问题
表格重载两种方式: 方式一: tableIns.reload(options) 注意这种方式的重载是不会携带上次数据加载时的where值 //使用 第一次渲染返回的对象 var table ...
- Tukey‘s test方法 异常值
如何计算异常值 异常值就是和其他样本数据有显著差异的值.这个词在统计学中经常用到,可以表示数据异常或测量错误.明白算异常值的方法,对于正确理解数据非常有用,而且会引出更精确的结论.以下介绍一个很简单的 ...
- Mac改键软件Karabiner使用教程
Mac改键软件Karabiner使用教程 目前Mac上比较好用的改键软件是Karabiner,不过对于最新的Sierra系统,Karabiner失效了.这里介绍的实际上是Karabiner-Eleme ...
- C# 部分类使用partial修饰
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace pati ...
- 计算机网络之互联网|因特网|万维网|HTTP|HTML之间的关系辨析
本博文基于知乎"Web 是什么意思?"一问而引起.(本文均属于博主从知乎上自身所答搬运而至). 如无特殊声明,括号()内以分号分隔的名词均等效. 本文如无特殊引用声明,则所有内容版 ...
- JavaScript之函数式编程思想初探
//result = 3*x + 5; var Mul3 = function(x){ return 3*x; } var Add5 = function(x){ return x + 5; } va ...
- CF1009F Dominant Indices
传送门 还是放个链接让泥萌去学一下把 orzYYB 题目中要求的\(f_{x,j}\),转移是\(f_{x,j}=\sum_{y=son_x} f_{y,j-1}\),所以这个东西可以用长链剖分优化, ...