题目大意:

一开始第一行是 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. MySQL提供的几种检索行数据的优化方式

    ICP(Index Condition Pushdown): 在MySQL5.6之前,存储引擎会通过遍历索引定位基表中 的行,然后返回给Server层,再去为这些数据进行WHERE后的条件过滤.MyS ...

  2. js 颜色随机切换

    生成随机颜色 方法1:RGB模式 function randomColor1() { var r=Math.floor(Math.random()*256); var g=Math.floor(Mat ...

  3. Scratch—点亮生日蜡烛

    过生日是小朋友们创作Scratch作品经常会用到的素材,今天介绍使用一些基础技能来点亮生日蜡烛的实现方法. 1.角色设计只有三种:生日蛋糕.未点燃的蜡烛.已点燃的蜡烛. 2.未点燃的蜡烛:在程序启动时 ...

  4. const函数返回自身的引用也是常量引用

    const函数返回自身的引用也是const 解决:根据对象是否为consr重载

  5. 【解决方法】You seem to have the current working directory in your LD_LIBRARY_PATH environment variable.

    参考地址:https://blog.csdn.net/qq_24755999/article/details/78722788 You seem to have the current working ...

  6. IDEA忽略不必要提交的文件

    1.在idea中安装插件用来生成和管理 .gitignore 文件,安装成功后重启idea 2.新建.gitignore 文件 3.将不需要提交的文件添加到.gitignore  4.删除缓冲文件 . ...

  7. Quartz.net任务调度(石英钟定时任务)

    好了,现在具体来说一下怎么使用Quartz.net 2.0. 1.到网上下载Quartz.net 2.0,下载完后解压,里面有vs.net2008和vs.net2010两个版本. 2.新建一个空项目, ...

  8. C# 循环中 直接索引 VS 缓存索引 性能测试

    using System; namespace TestCSharp { class MainClass { public class t1 { public b1 b = new b1(); } p ...

  9. Python 3.7的新特性

    Python 3.7为数据处理.脚本编译和垃圾收集优化以及更快的异步I/O添加了许多新类.python是一种旨在简化复杂任务的语言.python 3.7的最新版本已经正式休闲鹿进入beta发布阶段.P ...

  10. js入门第二篇之流程控制语句

    表达式语句: 一个表达式可以产生一个值,有可能是运算.函数调用 字面量 表达式可以放在任何需要值的地方. 语句: 语句可以理解成一个行为,循环语句和判断语句就是典型的语句,一个程序有多个语句组成. 流 ...