Repeat Number
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的更多相关文章
- 2014辽宁省赛 Repeat Number
问题 C: Repeat Number 时间限制: 1 Sec 内存限制: 128 MB [cid=1073&pid=2&langmask=0">提交][状态][论坛 ...
- Repeat Number(数论)
Repeat Number 题目描述: Definition: a+b = c, if all the digits of c are same ( c is more than ten), then ...
- WUSTOJ 1323: Repeat Number(Java)规律统计
题目链接:1323: Repeat Number Description Definition: a+b = c, if all the digits of c are same ( c is mor ...
- linux命令之 repeat 重复执行命令
$ vim ~/.bashrc function repeat() { number=$1 shift echo $@ for n in $(seq $number); do $@ done } $ ...
- React-Native 动画优化
前言 动画对于客户端来说是非常重要的一部分,直接影响到应用的用户体验.前端对于动画优化通常使用CSS3样式来实现动画,以利用GPU加速特性.而React-Native由于渲染模式的不同,无法使用CSS ...
- Three.js typescript definitely typed 文件
最近学习three.js,想用typescript编写代码,去http://definitelytyped.org/找了一圈没有发现three.js的definitely typed文件. 好吧,花了 ...
- python中多线程与非线程的执行性能对比
此对比说明了一件事: 如果是IO型应用,多线程有优势, 如果是CPU计算型应用,多线程没必要,还有实现锁呢. #!/usr/bin/env python # -*- coding: utf-8 -*- ...
- 统计单词个数及词频(C++实现)
#include<iostream> #include<fstream> #include<string> using namespace std; struct ...
- HTML5大数据可视化效果(二)可交互地铁线路图
前言 最近特别忙,承蒙大伙关照,3D机房的项目一个接着一个,领了一帮小弟,搞搞传帮带,乌飞兔走,转眼已经菊黄蟹肥……有个小弟很不错,勤奋好学,很快就把API都摸透了,自己折腾着做了个HTML5的魔都的 ...
随机推荐
- CSS实例:水平居中和垂直居中的多种解决方案
1.单行垂直居中 文字在层中垂直居中vertical-align 属性是做不到的.我们这里有个比较巧妙的方法就是:设置height的高度与line-height的高度相同! Example Sourc ...
- Android_神奇的android:clipChildren属性
正文 一.效果图 看到这个图时你可以先想想如果是你,你怎么实现这个效果.马上想到用RelativeLayout?NO,NO,NO,,, 二.实现代码 <?xml version="1. ...
- 【原】YUI Test自动化测试实例详解
测试在软件开发中至关重要,目前针对不同的开发语言,都有比较成熟的测试框架,如jUnit,cUnit,cppUnit,nUnit等,我们统称为xUnit,他们的都遵守统一的规则: 针对代码测试 断言 启 ...
- 前端开发面试题收集 css
什么是CSS盒子模型 页面上的每个元素都被浏览器看做是一个矩形的盒子. 由内容.填充.边框.边界组成. 什么是 css sprite 将多个图片拼接在一个图片中,通过background-positi ...
- jchat:linux聊天程序4:客户端
makefile: jchat: main.o login.o regist.o tcp.o gcc -w main.o login.o regist.o tcp.o -o jchat rm -f * ...
- React 从0开始 消息传递
React笔记 React 数据决定DOM 以往的做法是通过JS去操作DOM 将数据填充 JSX Jsx javascript xml HTML的结构组装到js中 jsx使用style的时候 不能直接 ...
- jQuery学习-事件之绑定事件(五)
大家应该还记得dispatch方法中有这么一段代码: event = jQuery.event.fix( event ); event的修复是在fix这个方法中的,而在fix中是通过 new jQue ...
- 论山寨手机与Android联姻 【10】SmartPhone的通信机制
上一章我们说到,智能手机 == 电脑 + 移动网卡,这个提法比较粗略,更精准的提法应当是,智能手机的硬件结构分为应用程序处理器AP,和基带处理器BP两个部分.虽然AP部分的功能与电脑主板基本类似,但是 ...
- Aix字符集
aix 安装中文字符集 1.看到系统安装过的字符集 locale -a 2.安装 smitty-->System Environments-->Manage Language Enviro ...
- iOS 开发常用设置
1. iOS设置app应用程序文件共享 设置流程 xcode 打开项目----在 info.plist 文件,添加 UIFileSharingEnabled 并设置属性为 YES, 在app内部,将您 ...