题目大意:

一开始第一行是 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. 【坑】关于使用 maven 创建 web 项目以后,el 表达式不被识别的解决方法

    问题描述: 在学习 Ajax 的时候,使用资源路径,博主本着不要硬编码,局使用 el 表达式进行读取项目名,然后发现 el 表达式没有被识别,而是当做字符串 ${pageContext.request ...

  2. 有关Linux服务器的一些配置

    1.Redis部署 1.版本 redis-3.0.72.上传解压 3.编译 make && make install 问题:/bin/sh: cc: command not found ...

  3. Nginx安装配置|Nginx反向代理|Nginx支持HTTPS|Nginx重定向

    Nginx安装配置 可以直接看到最下面的HTTPS. Nginx安装 我的系统如下: No LSB modules are available. Distributor ID: Ubuntu Desc ...

  4. SqlServer用sql语句清理log日志

    原文:SqlServer用sql语句清理log日志 USE[master] ALTER DATABASE [Center] SET RECOVERY SIMPLE WITH NO_WAIT ALTER ...

  5. “org/apache/commons/logging/LogFactory”错误的解决方式

    用spring-framework-4.2.6.RELEASE-dist时,发生了如下的错误: [java] view plain copy Exception in thread "mai ...

  6. 踩坑记录-连接 MongoDB Compass Community 报错

    在控制台输入 mongod 启动 mongodb服务,地址栏输入http://localhost:27017/ 能看到下图,表示服务启动成功. 打开"MongoDB Compass Comm ...

  7. impdp时报错ORA-39083&ORA-01917

    转自:http://www.codes51.com/article/detail_146662.html impdp时报错ORA-39083&ORA-01917ORA-39083: 对象类型 ...

  8. OGG 自动重启脚本

    6-20 * * * /oggdata/log/oggautorestart.sh >/oggdata/log/crontab_oggautorestart.log 2>&1 [说 ...

  9. shell code

  10. 从c到c++<一>

    逻辑型也称布尔型,其取值为true(逻辑真)和false(逻辑假),存储字节数在不同编译系统中可能有所不同,VC++中为1个字节. 声明方式: bool result; result=true; 可以 ...