题意:从奇数列 1 3 5 7 9 ....  偶数列2 4 6 8 10...分别轮流取 1 2 4 ....2^n 个数构成新数列 求新数列的区间和 (就一次询问)

思路:首先单次区间和就是一个简单的类似前缀和就可以搞定  那么如何求新数列的和呢

  我们明确一个观点:原数列的区间和结果显而易见  那么题目就转化成  奇数列和偶数列分别取了多少个数

  因为取数的数字的以2的幂递增的,所以 l r(<=1e18)  log2(1e18)很简单过

  而有了数量结果可以用0(1)的时间算出来

  记得瞎MOD 和LL

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+;
ll solve(ll x){
int flag=;
ll sum=;
ll sumodd=,sumeven=;
ll i;
if(x<=)return ;
for(i=;;i<<=){
sum+=i;
if(sum>x){
sum-=i;
if(flag==)sumodd+=(x-sum);
else sumeven+=(x-sum);
break;
}
if(flag==)sumodd+=i;
else sumeven+=i;
flag^=;
}
return ( (sumodd%mod)*(sumodd%mod)+(sumeven+)%mod*(sumeven%mod))%mod; }
int main(){
ll l,r;
cin>>l>>r;
cout<<(solve(r)-solve(l-)+mod)%mod<<endl; return ;
}

Codeforces Round #553 (Div. 2) C. Problem for Nazar 数学的更多相关文章

  1. Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

  2. Codeforces Round #622 (Div. 2) B. Different Rules(数学)

    Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...

  3. Codeforces Round #553 (Div. 2) C

    C. Problem for Nazar time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #553 (Div. 2)

    传送门 A. Maxim and Biology 题意: 给出一个串s,问最少需要多少步操作使得串s包含"ACTG"这个子串,输出最少操作次数: 题解: 枚举每个位置 i,求出将 ...

  5. Codeforces Round #553 (Div. 2) 题解

    昨晚深夜修仙上紫记,虽然不错还是很有遗憾的. A. Maxim and Biology 看完就会做的题,然而手速跟不上 #include<cstdio> #include<iostr ...

  6. Codeforces Round #553 (Div. 2)/codeforces1151

    CodeForces1151 Maxim and Biology 解析: 题目大意 每次可以使原串中的一个字符\(+1/-1\),\(Z + 1\to A, A -1\to Z\),求至少修改多少次可 ...

  7. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #553 (Div. 2) 【C. Problem for Nazar】

    题目大意: 一开始第一行是 1,第二行是2 4 ,第三行是3 5 7 9 ,类似这样下去,每一行的个数是上一行的个数,然后对这些点从第一个进行编号,问你从[l,r]区间数的和. 思路:分别求出奇数和偶 ...

  9. Codeforces Round #553 (Div. 2) D题

    题目网址:http://codeforces.com/contest/1151/problem/D 题目大意:给出n组数对,(ai , bi),调整这n组数对的位置,最小化 ∑(ai*( i -1)+ ...

随机推荐

  1. myeclipse和jdk的安装和配置

    一.安装JDK 1.下载得到jdk-8u11-windows-i586.1406279697.exe,直接双击运行安装,一直next就可以,默认是安装到系统盘下面Program Files,我这里装在 ...

  2. SQL 查询数据库中包含指定字符串的相关表和相关记录

    declare @str varchar(100)set @str='我要找的' --要搜索的字符串 declare @s varchar(8000)declare tb cursor local f ...

  3. python_08 函数式编程、高阶函数、map、filter、reduce函数、内置函数

    函数式编程 编程方法论: 1.面向过程 找到解决问题的入口,按照一个固定的流程去模拟解决问题的流程 (1).搜索目标,用户输入(配偶要求),按照要求到数据结构内检索合适的任务 (2)表白,表白成功进入 ...

  4. ---command line edit and histroy of perl cpan shell

    https://www.redhat.com/archives/psyche-list/2003-February/msg00494.html perl -MCPAN -e shell > in ...

  5. install oracle 12c on redhat

    ---恢复内容开始--- 1.  确定VM的硬盘空间是否够  df- h, 硬盘空间free disk 15G 比较稳妥 2. 确定好网络,需要remote connect   ifconfig 3. ...

  6. C++ 11 创建和使用 unique_ptr

    unique_ptr 不共享它的指针.它无法复制到其他 unique_ptr,无法通过值传递到函数,也无法用于需要副本的任何标准模板库 (STL) 算法.只能移动unique_ptr.这意味着,内存资 ...

  7. phpcms的一些问题 乱码,安装

    一.乱码:我这的网站出现的乱码情况:后台栏目名乱码,迁站后更新缓存,再更新栏目,内容,前台都乱码. 找了半天原因,经过本地测试,没问题,一上线就出现问题,不同点就是线上的数据库版本是mysql5.5, ...

  8. Linux 网络配置文件解析

    Linux 网络配置文件解析 网络配置文件路径/etc/sysconfig/network-scripts/ifcfg-*     *代表网卡名 vim /etc/sysconfig/network- ...

  9. adb、monkey常用命令

    adb.monkey常用命令 1.查看连接设备 adb devices 2.连接android模拟器 adb connect 127.0.0.1:62001 3.安装软件 adb install 这个 ...

  10. Boost::bind使用详解

    1.Boost::bind 在STL中,我们经常需要使用bind1st,bind2st函数绑定器和fun_ptr,mem_fun等函数适配器,这些函数绑定器和函数适配器使用起来比较麻烦,需要根据是全局 ...