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的魔都的 ...
随机推荐
- iOS 类管理
CocoaPods安装和使用教程 Code4App 原创文章.转载请注明出处:http://code4app.com/article/cocoapods-install-usage 目录 CocoaP ...
- [Effective C++系列]-透彻了解inlining的里里外外
Understand the ins and outs of inlining. [原理] Inline函数背后的做法是将“对函数的每一个调用”都用函数本体(function body)替换之.其 ...
- 【原】YUI Test自动化测试实例详解
测试在软件开发中至关重要,目前针对不同的开发语言,都有比较成熟的测试框架,如jUnit,cUnit,cppUnit,nUnit等,我们统称为xUnit,他们的都遵守统一的规则: 针对代码测试 断言 启 ...
- c语言函数实现交换两个数的值
代码: #include <stdio.h> void swap(int x,int y) { int temp; temp = x; x = y; y = temp; printf(&q ...
- [solaris]odbc-oracle,简单测试
#include <string> #include <iostream> #include <stdio.h> #include <sql.h> #i ...
- W5300E01-ARM 交叉编译器(Cross Compiler)用户手册
W5300E01-ARM是基于W5300的ARM功能测试评估板: 1 简介 当用户的开发环境与目标系统不同时就会用到交叉编译器. 例如,当开发基于ARM的嵌入式系统时,用户就需要在电脑上写出 ...
- 给ecshop后台增加管理功能页面
给ecshop后台增加管理功能页面 比如我们增加一个统计报表叫做 物流费用统计报表 放在后台“报表统计”栏目中 具体操作步骤: 第一步,我们要添加一个菜单到后台,然后设置语言项,最后设置权限,这样,后 ...
- MySQL RR隔离 读一致性
MySQL RR 模式下 事务隔离问题: Session 1: mysql> select * from test; +------+------+ | id | name | +------+ ...
- C语言入门(16)——C语言的数组
和结构体类似,数组也是一种复合数据类型,它由一系列相同类型的元素组成.C语言支持一维数组和多维数组.如果一个数组的所有元素都不是数组,那么该数组称为一维数组. 一维数组的定义方式 在C语言中使用数组必 ...
- Android:实现仿 美团/淘宝 多级分类菜单效果
本例要实现的是诸如美团/淘宝/百度糯米 多级分类菜单效果.当分类数量许多时能够考虑採用两级分类.而诸如美团这样的表现方式是一个不错的选择. 首先上效果图: 主要代码: 1. PopupWin ...