题目大意:

一开始第一行是 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. C++操作文件行(读取,删除,修改指定行)

    /******************************************************** Copyright (C), 2016-2018, FileName: main A ...

  2. 下载GDB调试工具peda

    命令: 1.git clone https://github.com/longld/peda.git ~/peda 2.echo "source ~/peda/peda.py" & ...

  3. scrapy 爬取纵横网实战

    前言 闲来无事就要练练代码,不知道最近爬取什么网站好,就拿纵横网爬取我最喜欢的雪中悍刀行练手吧 准备 python3 scrapy 项目创建: cmd命令行切换到工作目录创建scrapy项目  两条命 ...

  4. spring cloud微服务实践四

    spring cloud的hystrix还有一个配搭的库hystrix-dashboard,它是hystrix的一款监控工具,能直观的显示hystrix响应信息,请求成功率等.但是hystrix-da ...

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

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

  6. Typora 的使用

    一. Typora的markdown语法 1.标题 使用简单的ctr+数字健,就可以快速完成各种级别的标题 #一阶标题 或者快捷键Ctrl+1 ##二阶标题 或者快捷键Ctrl+2 ##二阶标题 或者 ...

  7. (二十七)JSP标签之核心标签

    一.诞生 JSTL标签库的使用是为弥补html标签的不足,规范自定义标签的使用而诞生的.使用JSLT标签的目的就是不希望在jsp页面中出现java逻辑代码. 二.JSTL 分类 核心标签(用得最多) ...

  8. 分布式事务(ACID特性、CAP定律)

    普通事务和分布式事务的区别: 普通事务就是一般所说的数据库事务,事务是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成.当事务被提交给了DBMS(数据库管理系统),则DBMS(数 ...

  9. iOS热更新实现方式

    heart.jpg 苹果静止热更新,可惜我的是企业app,没有这些约束了,随便用.(当然有些热更新已经可以通过苹果审核了,比如JSPatch)官网说的: JSPatch 平台 SDK 1.7.2 以上 ...

  10. MySQL之日期时间函数

      1.NOW() 用法:显示当前日期和时间 举例: mysql> select NOW(); +---------------------+ | NOW() | +-------------- ...