题意:从奇数列 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. c# post 接收传来的文件

    private void UploadFile() { // //......其他代码 // HttpFileCollection files = HttpContext.Current.Reques ...

  2. 一个判断I2C总线通信异常原因的方法

    此问题由某客户提出,应用处理器 AP与 MCU进行 I2C通信,通信会经常发生异常,需要定位原因. 首先需要定位的是因为哪个器件发的波形不正确导致通信异常,所以我们在 I2C 线路上增加了以下处理,增 ...

  3. ios unicode

    转义字符,反斜扛\ \u 后跟4位16进制数 \U 后跟8位16进制数

  4. TensorFlow学习之二

    二.常用操作符和基本数学函数 大多数运算符都进行了重载操作,使我们可以快速使用 (+ - * /) 等,但是有一点不好的是使用重载操作符后就不能为每个操作命名了. 1  算术操作符:+ - * / % ...

  5. 监测SQLServer数据库中表的数据变化 方案

    sqlDependency提供了这样一种能力:当被监测的数据库中的数据发生变化时,SqlDependency会自动触发OnChange事件来通知应用程序,从而达到让系统自动更新数据(或缓存)的目的. ...

  6. Dart 基础重点截取 Dart 2 20180417

    官网教程 https://www.dartlang.org/guides/language/language-tour dart是一个单线程的语言,没有多线程 Final and const If y ...

  7. svn 清理失败的解决方法

    首先 下载 SQLiteSpy   工具, 解压后如下图所示, 打开 .exe  应用程序,File ,opendatabase 选中wc.db  然后执行 delete  from  work_qu ...

  8. .net like模糊查询参数化

    List<SqlParameter> paras = new List<SqlParameter>(); if (!string.IsNullOrEmpty(ciName)) ...

  9. [leetcode]156.Binary Tree Upside Down颠倒二叉树

    Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that ...

  10. java_22.1 Map 的应用

    定义一个九年级,年级里面有一班和二班.且有属于自己班的学生. 九年级 一班 001 张三 002  李四 二班 001 王五 002 马六 把同学都遍历出来 package demo; import ...