解法

又是一道结论题?

我的做法比较奇怪且没有证明

#include <cstdio>
#include <cmath>
#define ll long long int main(){
ll ans = 0;
ll n, bs = 1;
scanf("%I64d", &n);
while (n > 1){
ans += (n >> 1) * bs;
n -= (n >> 1);
bs <<= 1;
}
printf("%I64d", ans);
return 0;
}

如果没看懂,请去

CF官方题解及其证明

[CF959E]Mahmoud and Ehab and the xor-MST题解的更多相关文章

  1. Codeforces 862C - Mahmoud and Ehab and the xor

    862C - Mahmoud and Ehab and the xor 思路:找两对异或后等于(1<<17-1)的数(相当于加起来等于1<<17-1),两个再异或一下就变成0了 ...

  2. Coderfroces 862 C. Mahmoud and Ehab and the xor

    C. Mahmoud and Ehab and the xor Mahmoud and Ehab are on the third stage of their adventures now. As ...

  3. [CF959A]Mahmoud and Ehab and the even-odd game题解

    题意简述 一个数n,Mahmoud珂以取(即如果取\(k\),使\(n = n - k\))一个正偶数,Ehab珂以取一个正奇数,一个人如果不能取了(对于Mahmoud和Ehab \(n = 0\), ...

  4. CF959E Mahmoud and Ehab and the xor-MST 思维

    Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem t ...

  5. CodeForces 959E Mahmoud and Ehab and the xor-MST (MST+找规律)

    <题目链接> 题目大意: 给定一个数n,代表有一个0~n-1的完全图,该图中所有边的边权为两端点的异或值,求这个图的MST的值. 解题分析: 数据较大,$10^{12}$个点的完全图,然后 ...

  6. 【构造】【分类讨论】Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

    题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0, ...

  7. codeforces 862 C. Mahmoud and Ehab and the xor(构造)

    题目链接:http://codeforces.com/contest/862/problem/C 题解:一道简单的构造题,一般构造题差不多都考自己脑补,脑洞一开就过了 由于数据x只有1e5,但是要求是 ...

  8. CodeForces - 862C Mahmoud and Ehab and the xor(构造)【异或】

    <题目链接> 题目大意: 给出n.m,现在需要你输出任意n个不相同的数(n,m<1e5),使他们的异或结果为m,如果不存在n个不相同的数异或结果为m,则输出"NO" ...

  9. 【Codeforces Round #435 (Div. 2) C】Mahmoud and Ehab and the xor

    [链接]h在这里写链接 [题意] 让你组成一个n个数的集合,使得这n个数的异或和为x; x<=1e5 每个数最大1e6; [题解] 1e5<=2^17<=2^18<=1e6的 ...

  10. 862C - Mahmoud and Ehab and the xor(构造)

    原题链接:http://codeforces.com/contest/862/problem/C 题意:给出n,x,求n个不同的数,使这些数的异或和为x 思路:(官方题解)只有n==2&&am ...

随机推荐

  1. 从 spring-cloud-alibaba-nacos-config 进入 nacos-client

    sc 的 bootstrap context 是 main application context 的 parent,需要在 main application context 中使用的 bean 可以 ...

  2. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_07 缓冲流_5_BufferedWriter_字符缓冲输出流

    使用newLine来换行 同样的效果 println的源码里面其实就用的就是newLine()

  3. sprint test 添加事务回滚机制

    1.原因: 单元测试的时候频繁操作数据库需要修改很多数据,造成不必要的操作,添加事务之后就可以重复对一条数据进行操作,并且在返回结果后进行回滚. 2.解决: 原先继承的是  AbstractJUnit ...

  4. [CERC2016]Hangar Hurdles

    你正在评估一些关于一个巨型飞机仓库的建设计划.飞机仓库的地面可以表示为n行n列的网格图,其中每个格子要么是空的,要么有障碍物.行从上到下依次被编号为1到n,列从左到右依次被编号为1到n.存放飞机零件的 ...

  5. Python3的基本数据类型

    2.1. Python3中六个标准的基本数据类型: Number(数字) String(字符串) Sets(集合) Tuple(元组) List(列表) Dictionary(字典) 2.2. Pyt ...

  6. java二周的学习总结

    一转眼二周就过去了,个人觉得虽然java和C语言有差异,但差别并不大,因为语法语句方面都是差不多的,因为我上个学期并没有很认真的学好C语言,所以我这个学期更希望学好java,java方面还是挺有趣的, ...

  7. [BZOJ5099]Pionek

    Description 给 \(n\) (\(n\le 2\times 10 ^5\)) 个向量,现在你在 \((0,0)\) ,选择一些向量使你走的最远. Solution 自己的想法:按极角排序后 ...

  8. 【题解】Oh My Holy FFF

    题目大意   有\(n\)个士兵(\(1 \leq n \leq 10^5\)),第\(i\)个士兵的身高为\(h_{i}\),现在要求把士兵按照原来的顺序分成连续的若干组,要求每组的士兵数量不超过\ ...

  9. C# Lodop与C-Lopdop选择打印机

    原文:https://www.cnblogs.com/huaxie/p/9766886.html https://www.cnblogs.com/huaxie/p/10857490.html http ...

  10. Linux终端复用工具tmux的使用和配置

    1. 会话管理 新建会话 $ tmux new -s session-one -d -s:指定回话名称 -d:会话在后台运行 查看所有会话 $ tmux ls session-one: 1 windo ...