题意:从奇数列 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. Microsoft DQS sqlException 0x80131904 - SetDataQualitySessionPhaseTwo

    遇到这个问题的原因可以从报错信息看出来,大概率是.net framework的问题 可以尝试如下解决途径 1. regenerate .net Assemble for DQS 2. 如果步骤一无法解 ...

  2. GDI+_入门教程【一】

    GDI For VisualBasic6.0 [一]文件下载:GDI+ For VB6[一] 简单绘图实例演示百度网盘 1 '以下为作者[vIsiaswx]的教程 '(该教程发布的原地址已无法访问,此 ...

  3. vs2010提取资源

    setlocal enabledelayedexpansion rem cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin set R ...

  4. docker-compose学习

    该实践是在已经安装了docker的基础上,如果还未安装docker,请先安装docker : https://www.cnblogs.com/theRhyme/p/9813019.html docke ...

  5. netstat 常用参数总结

    netstat 是一个机器网络查看工具 . 网络连接有哪些参数? 

  6. js 一些兼容检测

    1. IE5.0之前不支持 document.getElementById(),但存在 document.all[] function getElementById(id) { if(document ...

  7. 220. Contains Duplicate III 数组指针差k数值差t

    [抄题]: Given an array of integers, find out whether there are two distinct indices i and j in the arr ...

  8. [leetcode]21. Merge Two Sorted Lists合并两个链表

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  9. Swift 反射机制,命名空间

    1. 知道 Swift 中有命名空间        - 在同一命名空间下,全局共享!        - 第三方框架使用 Swift 如果直接拖拽到项目中,从属同一个命名空间,很有可能冲突!       ...

  10. 201621123002《JAVA程序设计》第一周学习总结

    1.本周学习总结 1.下载并安装JDK,设定path变量 Java SE Downloads 2.了解JD与JRE的区别与联系 3.下载eclipse并完成实现简单程序 Downloads 4.使用命 ...