http://blog.csdn.net/angon823/article/details/51484906

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
LL solve(LL x){
if(x<=)return ;
LL cur=,ret=;
while(cur<x){
cur=cur*+;
}
cur=(cur-)/;
ret=(cur+)/;
LL res=x-cur-;
return ret++res-(ret-solve(cur-res));
}
int main(){
int T;
scanf("%d",&T);
while(T--){
LL l,r;
scanf("%I64d%I64d",&l,&r);
printf("%I64d\n",solve(r)-solve(l-));
}
return ;
}

HDU 5694 BD String 递归暴力的更多相关文章

  1. HDU 5694——BD String——————【递归求解】

    BD String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  2. HDU 5694 BD String 迭代

    BD String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5694 Description Problem Description 众所周知, ...

  3. HDU 5311 Hidden String (暴力)

    题意:今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下 ...

  4. hdu-5694 BD String(分治)

    题目链接: BD String Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) ...

  5. HDU 4054 Number String

    HDU 4054 Number String 思路: 状态:dp[i][j]表示以j结尾i的排列 状态转移: 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][j-1] + ...

  6. HDU 2920 分块底数优化 暴力

    其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...

  7. BD String

    BD String Accepts: 388 Submissions: 1164 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/ ...

  8. HDU 5311 Hidden String (优美的暴力)

    Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) ...

  9. HDU 5944 Fxx and string(暴力/枚举)

    传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

随机推荐

  1. C# Windows - ListBox&CheckedListBox

    ListBox和CheckedListBox类的属性 属性 说明 SelectedIndex 这个值表明列表框中选中项的基于0的索引 ColumnWidth 在包含多个列的列表框中,这个属性指定列宽 ...

  2. CSS3圆角气泡框,评论对话框

    <title>CSS3圆角气泡框,评论对话框</title> <style> body { ; ; font:1em/1.4 Cambria, Georgia, s ...

  3. maven eclipse web项目流程(简化内容)

    1.maven eclipse 环境搭建 1.1 下载解压配置环境变量(解压.环境变量maven目录到bin.setting.xml 改本地仓库) 1.2 eclipse插件安装配置(link安装.加 ...

  4. 1074: [SCOI2007]折纸origami - BZOJ

    Description 桌上有一张边界平行于坐标轴的正方形纸片,左下角的坐标为(0,0),右上角的坐标为(100,100).接下来执行n条折纸命令.每条命令用两个不同点P1(x1,y1)和P2(x2, ...

  5. hibernate hql 大全

    Hibernate配备了一种非常强大的查询语言,这种语言看上去很像SQL.但是不要被语法结构 上的相似所迷惑,HQL是非常有意识的被设计为完全面向对象的查询,它可以理解如继承.多态 和关联之类的概念. ...

  6. UnitOfWork机制的实现和注意事项

    UnitOfWork机制 /*一点牢骚: * UnitOfWork机制的蛋疼之处: *    UnitOfWork机制,决定了插入新的实体前,要预先设置数据库中的主键Id,尽管数据库自己生产主键. * ...

  7. VIM的高级使用

    VIM的高级使用  转:http://www.cnblogs.com/itech/archive/2012/02/22/2363111.html 1)一些常用的Vim配置,在~/.vimrc中 syn ...

  8. PHP 怎么随机获取数组里面的值

    注意array_rand随机返回的是KEY值的集合 <?php srand((float) microtime() * 10000000); $input = array("Neo&q ...

  9. [itint5]判断是否为二叉搜索树

    http://www.itint5.com/oj/#25 这题在leetcode上是用中序遍历来做的,但是这里由于有相等的情况,即左子树小于等于根,这样中序遍历无法完全判定.可以用递归来做,用递归给出 ...

  10. MyBatis的分页操作(MySQL)

    1.无条件分页: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC ...