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(看题解)的更多相关文章

  1. codeforces 460D Little Victor and Set(构造、枚举)

    最近的CF几乎都没打,感觉挺水的一个题,不过自己仿佛状态不在,看题解才知道做法. 输入l, r, k (1 ≤ l ≤ r ≤ 1012; 1 ≤ k ≤ min(106, r - l + 1)). ...

  2. Codeforces 229E Gifts 概率dp (看题解)

    Gifts 感觉题解写的就是坨不知道什么东西.. 看得这个题解. #include<bits/stdc++.h> #define LL long long #define LD long ...

  3. Codeforces 460D Little Victor and Set --分类讨论+构造

    题意:从区间[L,R]中选取不多于k个数,使这些数异或和尽量小,输出最小异或和以及选取的那些数. 解法:分类讨论. 设选取k个数. 1. k=4的时候如果区间长度>=4且L是偶数,那么可以构造四 ...

  4. Codeforces 1155F Delivery Oligopoly dp(看题解)

    看别人写的才学会的... 我们考虑刚开始的一个点, 然后我们枚举接上去的一条一条链, dp[mask]表示当前已经加进去点的状态是mask所需的最少边数. 反正就是很麻烦的一道题, 让我自己写我是写不 ...

  5. 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 ...

  6. Codeforces 380D Sereja and Cinema (看题解)

    Sereja and Cinema 首先我们可以发现除了第一个人, 其他人都会坐在已入坐人的旁边. 难点在于计算方案数.. 我们可以从外往里把确定的人用组合数算上去,然后缩小范围. #include& ...

  7. Codeforces 442D Adam and Tree dp (看题解)

    Adam and Tree 感觉非常巧妙的一题.. 如果对于一个已经建立完成的树, 那么我们可以用dp[ i ]表示染完 i 这棵子树, 并给从fa[ i ] -> i的条边也染色的最少颜色数. ...

  8. Codeforces 915G Coprime Arrays 莫比乌斯反演 (看题解)

    Coprime Arrays 啊,我感觉我更本不会莫比乌斯啊啊啊, 感觉每次都学不会, 我好菜啊. #include<bits/stdc++.h> #define LL long long ...

  9. Codeforces 1101F Trucks and Cities dp (看题解)

    Trucks and Cities 一个很显然的做法就是二分然后对于每个车贪心取check, 这肯定会TLE, 感觉会给人一种贪心去写的误导... 感觉有这个误导之后很难往dp那个方向靠.. dp[ ...

随机推荐

  1. 自动升级CentOS Python至官方最新版

    #!/bin/bash # .检查当前系统Python版本 python_old_version=$(python -V >& | awk '{print $2}') echo &quo ...

  2. Kafka-Monitor

    kafka Monitor 监测Kafka集群状态 Topic.Consumer Group列表 图形化展示 topic 和 consumer 之间的关系 图形化展示 consumer 的 Offse ...

  3. js计算数字长度

    js调用toString方法转为字符串后取长度 var num = 123; alert(num.toString().length);

  4. A - The Water Bowls POJ - 3185 (bfs||高斯消元)

    题目链接:https://vjudge.net/contest/276374#problem/A 题目大意:给你20个杯子,每一次操作,假设当前是对第i个位置进行操作,那么第i个位置,第i+1个位置, ...

  5. A - 低阶入门膜法 - K-th Number (主席树查询区间第k小)

    题目链接:https://cn.vjudge.net/contest/284294#problem/A 题目大意:主席树查询区间第k小. 具体思路:主席树入门. AC代码: #include<i ...

  6. WPS 表格筛选两列相同数据-完美-2017年11月1日更新

    应用: 1.选出A列中的数据是否在B列中出现过: 2.筛选出某一批序号在一个表格里面的位置(整批找出) 3.其实还有其他很多应用,难描述出来... ... A列中有几百的名字,本人想帅选出B列中的名字 ...

  7. 实现Servlet容器一

    本文是阅读<深度解析Tomcat>的笔记. 源码:http://www.brainysoftware.com/source/9780975212806.zip├── src│   └── ...

  8. 求web前端面试题库及答案

    1.对WEB标准以及W3C的理解与认识 标签闭合.标签小写.不乱嵌套.提高搜索机器人搜索几率.使用外 链css和js脚本.结构行为表现的分离.文件下载与页面速度更快.内容能被更多的用户所访问.内容能被 ...

  9. 重装系统,出现:Units specified don't exist SHSUCDX can't install

    重装系统,出现:Units specified don't exist SHSUCDX can't install 解决方案1: 首先是你的硬盘分区不对吧 先用PQ格成ntfs或far32 进PE把C ...

  10. Linux下rsyslog日志收集服务环境部署记录【转】

    rsyslog 可以理解为多线程增强版的syslog. 在syslog的基础上扩展了很多其他功能,如数据库支持(MySQL.PostgreSQL.Oracle等).日志内容筛选.定义日志格式模板等.目 ...