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. C# Winform中慎用Application.DoEvents

    private void Add() { ; i < ; i++) { Button button = new Button(); button.Width = ; button.Height ...

  2. 安卓中location.href或者location.reload 不起作用

    链接:https://www.cnblogs.com/joshua317/p/6163471.html 在移动wap中,经常会使用window.location.href去跳转页面,这个方法在绝大多数 ...

  3. AES加解密算法

    直接粘代码,该类是基于微信公众号消息加密解密所提供的PHP DEMO改造而来,目前使用于彬彬大学APP接口token校验中. php的mcrypt 扩展已经过时了大约10年,并且用起来很复杂.因此它被 ...

  4. Vue.js用脚手架创建项目

    安装全局脚手架 cnpm install vue-cli -g vue --version 用脚手架创建项目 创建项目 运行项目 停止项目:Ctrl+C 修改端口 config - index.js ...

  5. mysql 架构 ~ PXC5.7.20安装尝试

    简介:今天来尝试下 pxc 5.7.20安装1 环境安装   yum install -y git scons gcc gcc-c++ openssl check cmake bison boost- ...

  6. mysql服务里面没有启动项

    解决:5.0版本:开始->运行->cmd,进到mysql安装的bin目录D:\MySQL\bin>mysqld.exe -installService successfully in ...

  7. 【逆向知识】VS程序反汇编找main函数

    工具:OllyICE 调试快捷键说明: F2键:设置断点,只要在光标定位的位置 F4键:程序运行到光标处 F7键:单步步入.功能同单步步过(F8)类似,区别是遇到 CALL 等子程序时会进入其中,进入 ...

  8. C++ 字符串的编码

    转载链接:https://www.cnblogs.com/akb48/p/5439154.html windows平台 char 表示单字符,占用一个字节 wchar_t 表示宽字符,占用两个字节 L ...

  9. [转]数据对齐对CPU的影响

    [转]http://www.cnblogs.com/wuzhenbo/archive/2012/06/05/2537465.html 1.前言 在IBM开发社区上发现一篇叫'Data alignmen ...

  10. c# 界面自适应大小

    采用在窗体事件SizeChanged里面代码控制大小和位置,达到自动适应窗体大小,这样做调整起来方便. private void FrmMain_SizeChanged(object sender, ...