题目大意:

一开始第一行是 1,第二行是2 4 ,第三行是3 5 7 9 ,类似这样下去,每一行的个数是上一行的个数,然后对这些点从第一个进行编号,问你从[l,r]区间数的和。

思路:分别求出奇数和偶数的个数。然后开始暴力。居然过了==

公式;前m个奇数的和是(m^2),前m个偶数的和是(m*(m+1))。

 #include<bits/stdc++.h>

 using namespace std;
#define int unsigned long long
#define mod 1000000007
int fqow(int a,int b){
int ans=;
while(b){
if(b%){
ans*=a;ans%=mod;
}
b/=;
a*=a;
a%=mod;
}
return ans;
}
int slove(int n){
int sodd=;int seven=;
int sum=;int add=;int cnt=;//次数
for(;;){
if(sum>n){
break;
}
add*=;
cnt++;//次数
if(cnt%){
sodd+=add;
}else{
seven+=add;
}
sum+=add;
}
if(cnt%){
int temp=n-(sum-add);
sodd-=add;
sodd+=temp;
}else{
int temp=n-(sum-add);
seven-=add;
seven+=temp;
} int ans1=(sodd%mod)*((sodd)%mod)%mod;
int ans2=(seven%mod)*((seven+)%mod)%mod;
return (ans1%mod+ans2%mod)%mod; }
signed main(){
int L,R;
cin>>L>>R;
// cout<<slove(L)<<" "<<slove(R)<<" "<<'\n';
cout<<(slove(R)%mod-slove(L-)%mod+mod)%mod<<'\n';
return ;
} /*
1 3 5 7 9 25
1 3 5 7 16
1 3 5 8
1 3 4 2 4 6
odd 1 4 16 64
even 2 8 32
2 4 6 12 2 4 6 8 20
*/

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

  1. Codeforces Round #343 (Div. 2)【A,B水题】

    A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...

  2. Codeforces Round #508 (Div. 2)【A,B,C,D】【实验室日常周赛训练】

    #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f3f3f #define int long long ...

  3. Codeforces Round #401 (Div. 2)【A,B,C,D】

    最近状态极差..水题不想写,难题咬不动..哎,CF的题那么简单,还搞崩了= =.真是巨菜无比. Codeforces777A 题意:略. 思路: 构造出3!次变换,然后输出就好. Code: #inc ...

  4. Codeforces Round #646 (Div. 2)【B. Subsequence Hate题解】

    具体思路已经在代码注释中给出,这里不再赘述. #include<iostream> #include<algorithm> using namespace std; int t ...

  5. Codeforces Round #367 (Div. 2) C. Hard problem

    题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字 ...

  6. Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  7. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  8. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  9. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

随机推荐

  1. 把QString写到文件中可以用toutf8()函数

    把QString写到文件中可以用toutf8()函数 QByteArray QString::toUtf8() const Returns a UTF-8 representation of the ...

  2. ckplayer获取播放时长一

    <div id="a1"></div> <div id="nowTime"></div> <script ...

  3. css line-height & 图片底部间隙的处理

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! 看大牛张鑫旭的视屏可能会理解的更深一些,点击这里 . line-height 的学习 line-heigh ...

  4. [yarn]yarn和npm的对比

    一.简介 NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从NPM服 ...

  5. java 框架-缓冲-Redis 1概述

    https://www.jianshu.com/p/56999f2b8e3b Redis 概述 在我们日常的Java Web开发中,无不都是使用数据库来进行数据的存储,由于一般的系统任务中通常不会存在 ...

  6. Citrix ADC 12.1 / NetScaler 12

    Citrix ADC 12.1 / NetScaler 12 参考 https://www.carlstalhood.com/netscaler-menu/netscaler-12/ Core – C ...

  7. [NOIP2018模拟赛10.25]瞎搞报告

    闲扯 最近有点颓,都修到好晚,早上起来和吔shi一样难受 忍着困意把题面看完,发现啥也不会,又是一场写暴力的模拟赛 T1发现似乎可以DP,顺手码了个 T2像个最小瓶颈路板子,但是只做过N^2算法的.. ...

  8. restTemplate源码解析(三)创建ClientHttpRequest请求对象

    所有文章 https://www.cnblogs.com/lay2017/p/11740855.html 正文 上一篇文章中,我们大体看了一下restTemplate的核心逻辑.再回顾一下核心代码 p ...

  9. HTML中关于 浮动 的简单说明

    1.首先,标签之所以有存在等级分类,是因为他们处于标准文档流(块级元素,行内元素,行内块元素)当中. 2.如何脱离标准文档流? 浮动 绝对定位 固定定位 这些可以让一个标签脱离标准文档流,而元素一旦脱 ...

  10. S2-029

    前言 S2-029漏洞是由于Struts2的i18n.text标签中的name属性的值会经过两次Ognl表达式解析. 正文 假设有如下缺陷代码: jsp文件中使用Struts2的i18n标签获取请求中 ...