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的魔都的 ...
随机推荐
- EXT.NET常用属性
Ext_数字输入框_Ext.form.NumberField: <mce:script type="text/javascript"><!-- /* Ext. ...
- MVC+simpleinjector 简单使用
一.首先添加NuGet包如下图
- input file 样式以及获取选择文件方法集合
样式一(http://www.cnblogs.com/jason-liu-blogs/archive/2013/06/13/3133377.html) <style> a{display: ...
- [Linked List]Rotate List
Total Accepted: 55428 Total Submissions: 250727 Difficulty: Medium Given a list, rotate the list to ...
- 《C++ Primer Plus 6th》读书笔记 - 第九章 内存模型和名称空间
1. 单独编译 1.1 头文件中常包含的内容: 函数原型 使用#define或const定义的符号常量 结构声明 类声明 模板声明 内联声明 1.2 只需将源代码文件加入到项目中,而不用加入头文件.这 ...
- 用Struts2标签实现Map的迭代
最近在做一个论坛,论坛通常分为几个主版块,每一个主版块下面又有几个子版块. 想不出更好的展现方式,最终采用了如下的方法来实现: 用一个Map,HashMap或者Treemap承载之.一个子版块名字对应 ...
- log4net自定义扩展及配置说明
log4net文件保存配置我就不说太多了,网上一大把的,数据库配置其实网上也有,只是我第一次按照网上的配置没有跑通,我就说下数据库配置需要注意的地方吧. 下面是一个log4net的数据库代码配置 pu ...
- Hive的安装配置
Hive的安装配置 Hive的安装配置 安装前准备 下载Hive版本1.2.1: 1.[root@iZ28gvqe4biZ ~]# wget http://mirror.bit.edu.cn/apac ...
- skynet newservice API参考
local skynet = require("skynet") skynet.start(start_func) c服务snlua启动后执行的第一个lua文件里面的主逻辑必定是s ...
- Linux05--Shell程序设计01
1.Shell脚本介绍 基本介绍: shell脚本是一个可执行的纯文本文件,由多个shell命令组成. 命令的执行是从上而下,从左而右的分析和执行 命令,参数间的多个空白也会被忽略 #是注释 #!用于 ...