Problem B: Repeat Number

Time Limit: 1 Sec  Memory Limit: 32 MB

Description

Definition: a+b = c, if all the digits of c are same ( c is more than ten),then we call a and b are Repeat Number. My question is How many Repeat Numbers in [x,y].

Input

There are several test cases.

Each test cases contains two integers x, y(1<=x<=y<=1,000,000) described above.

Proceed to the end of file.

Output

For each test output the number of couple of Repeat Number in one line.

Sample Input

1 10
10 12

Sample Output

5
2

HINT

If a equals b, we can call a, b are Repeat Numbers too, and a is the Repeat Numbers for itself.

上代码

#include<stdio.h>

int a[]={
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,
}; int lower_bound(int *array, int size, int key)
{
int first = , middle;
int half, len;
len = size; while(len > ) {
half = len >> ;
middle = first + half;
if(array[middle] < key) {
first = middle + ;
len = len-half-;
}
else
len = half;
}
return first;
} int main()
{
int x,y,i,mid;
while(~scanf("%d%d",&x,&y))
{
int p=lower_bound(a,,*x);
int q=lower_bound(a,,*y);
int ans=;
if(a[q]>*y) q--;
for(i=p;i<=q;i++)
{
mid = a[i]/;
if (a[i]%==)
{
if(mid-x < y-mid)
ans+=mid-x+;
else
ans+=y-mid+;
}
else
{
if(mid-x+ < y-mid)
ans+=mid-x+;
else
ans+=y-mid;
}
}
printf("%d\n",ans);
}
return ;
}
/**************************************************************
Problem: 2
User: hui
Language: C
Result: 正确
Time:0 ms
Memory:964 kb
****************************************************************/

Repeat Number的更多相关文章

  1. 2014辽宁省赛 Repeat Number

    问题 C: Repeat Number 时间限制: 1 Sec  内存限制: 128 MB [cid=1073&pid=2&langmask=0">提交][状态][论坛 ...

  2. Repeat Number(数论)

    Repeat Number 题目描述: Definition: a+b = c, if all the digits of c are same ( c is more than ten), then ...

  3. WUSTOJ 1323: Repeat Number(Java)规律统计

    题目链接:1323: Repeat Number Description Definition: a+b = c, if all the digits of c are same ( c is mor ...

  4. linux命令之 repeat 重复执行命令

    $ vim ~/.bashrc function repeat() { number=$1 shift echo $@ for n in $(seq $number); do $@ done } $ ...

  5. React-Native 动画优化

    前言 动画对于客户端来说是非常重要的一部分,直接影响到应用的用户体验.前端对于动画优化通常使用CSS3样式来实现动画,以利用GPU加速特性.而React-Native由于渲染模式的不同,无法使用CSS ...

  6. Three.js typescript definitely typed 文件

    最近学习three.js,想用typescript编写代码,去http://definitelytyped.org/找了一圈没有发现three.js的definitely typed文件. 好吧,花了 ...

  7. python中多线程与非线程的执行性能对比

    此对比说明了一件事: 如果是IO型应用,多线程有优势, 如果是CPU计算型应用,多线程没必要,还有实现锁呢. #!/usr/bin/env python # -*- coding: utf-8 -*- ...

  8. 统计单词个数及词频(C++实现)

    #include<iostream> #include<fstream> #include<string> using namespace std; struct ...

  9. HTML5大数据可视化效果(二)可交互地铁线路图

    前言 最近特别忙,承蒙大伙关照,3D机房的项目一个接着一个,领了一帮小弟,搞搞传帮带,乌飞兔走,转眼已经菊黄蟹肥……有个小弟很不错,勤奋好学,很快就把API都摸透了,自己折腾着做了个HTML5的魔都的 ...

随机推荐

  1. 简述UITextField的属性和用法

    0.     enablesReturnKeyAutomatically 默认为No,如果设置为Yes,文本框中没有输入任何字符的话,右下角的返回按钮是disabled的. 1.borderStyle ...

  2. iOS开发之网络请求(基于AFNetworking的再封装)

    最近一直很忙也没有什么时间写博客了.放假了休息一下,就写一篇博客来总结一下最近做项目中出现过的问题吧!!! 首先,在项目中我的起到了什么作用,无非就是把美工(UI设计师)给我们的图显示出来,然后再和服 ...

  3. 自定义不等高的cell-(storyboard)

    对比自定义等高cell,需要几个额外的步骤(iOS8开始才支持) 添加子控件和contentView之间的间距约束 设置tableViewCell的真实行高和估算行高 // 告诉tableView所有 ...

  4. jquery实现div垂直居中

    <html> <head> <meta charset="UTF-8"> <title></title> <scr ...

  5. jQuery 源码分析和使用心得 - 关于源码

    说到jQuery, 大家可能直觉的认为jQuery的源码应该就是一个jquery.xx.js这样的一个文件. 但是看到真正的源码的时候, 整个人都思密达了.jQuery的源码做的事远比你想象的多, 为 ...

  6. jQuery绑定事件-多种方式实现

    jQuery绑定事件-多种方式实现: <html> <head> <meta charset="utf-8" /> <script src ...

  7. bootstrap 简易模版

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  8. VS2008 自定义向导的default.js设置(DLL文件)

    function OnFinish(selProj, selObj) { try { var strProjectPath = wizard.FindSymbol('PROJECT_PATH'); v ...

  9. js打开新窗口的两种方式

    1.超链接<a href="http://www.jb51.net" title="脚本之家">Welcome</a>等效于js代码wi ...

  10. [Django] Pinax 项目下APP的 安装与使用

    Pinax下有数十个APP,怎么将这些APP集成到已有的Django 工程(http://www.cnblogs.com/xiaoqu/p/3196081.html)文件中去呢?现在用django-u ...