2014辽宁省赛 Repeat Number
问题 C: Repeat Number
时间限制: 1 Sec 内存限制: 128 MB cid=1073&pid=2&langmask=0">提交
提交: 23 解决: 7
[
题目描写叙述
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].
输入
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.
输出
For each test output the number of couple of Repeat Number in one line.
例子输入
1 10 10 12
例子输出
5 2
提示
If a equals b, we can call a, b are Repeat Numbers too, and a is the Repeat Numbers for itself.
这道题,我是暴力加二分过的,枚举c的可能值就可以。然后求中间点与边界差的最小值就可以
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
vector<int> G;
void init()
{
int k=1;
for(int i=0;i<6;i++)
{
k=k*10+1;
for(int j=1;j<=9;j++)
G.push_back(k*j);
}
}
int main()
{
int x,y;
init();
while(cin>>x>>y)
{
int p=lower_bound(G.begin(),G.end(),2*x)-G.begin();
int q=lower_bound(G.begin(),G.end(),2*y)-G.begin();
int ans=0;
//for(int i=0;i<10;i++)
// cout<<G[i]<<endl;
if(G[q]>2*y) q--;
// cout<<p<<" "<<q<<endl;
for(int i=p;i<=q;i++)
{
int mid = G[i]/2;
if (mid* 2 == G[i]) ans += mid-x < y-mid ? mid-x+1 : y-mid+1;
else ans+= mid-x+1 < y-mid ? mid-x+1 : y-mid;
}
cout<<ans<<endl;
}
return 0;
}
2014辽宁省赛 Repeat Number的更多相关文章
- Repeat Number
Problem B: Repeat Number Time Limit: 1 Sec Memory Limit: 32 MB Description Definition: a+b = c, if ...
- 【转】2014区域赛小结(牡丹江&&鞍山)by kuangbin
Posted on 2014年10月20日 by kuangbin 最后的两场区域赛结束了! ICPC生涯的最后两场区域赛,选择了前两个赛区——牡丹江和鞍山,主要是时间比较靠前,而且我向来对东北赛区有 ...
- 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 ...
- NBUT 1223 Friends number 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB Paula and Tai are couple. There are many stories betwee ...
- 10年省赛-Greatest Number (二分+暴力) + 12年省赛-Pick apples(DP) + UVA 12325(暴力-2次枚举)
题意:给你n个数,在里面取4个数,可以重复取数,使和不超过M,求能得到的最大的数是多少: 思路:比赛时,和之前的一个题目很像,一直以为是体积为4(最多选择四次)的完全背包,结果并不是,两两求和,然后二 ...
- 2015年辽宁省赛Interesting Tree
题目描述 Recently, Miss Huang want to receive a Tree as her birthday gift! (What a interesting person!) ...
- 13年山东省赛 The number of steps(概率dp水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud The number of steps Time Limit: 1 Sec Me ...
- [2013山东ACM]省赛 The number of steps (可能DP,数学期望)
The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...
随机推荐
- Windows Phone 8初学者开发—第23部分:测试并向应用商店提交
第23部分: 测试并向应用商店提交 原文地址:http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Begi ...
- 12.5.3 UNIVERSAL:最终的祖先类:
<pre name="code" class="html">12.5.3 UNIVERSAL:最终的祖先类: 你可以把 UNIVERSAL 看作最终 ...
- 工作线程AfxBeginThread的使用
工作线程通常用来执行一些后台任务,如:数据计算.后台杀毒等等.因为不需要创建窗口和处理用户消息,编写比较容易,在程序中只要调用AfxBeginThread 函数就可以创建并启动一个工作线程了. Afx ...
- 第二代map-reduce架构YARN解析
需求 我们在考虑hadoop map-reduce框架的时候,最重要需包括: 1. reliability 可靠性,主要是jobtracker,resource manager可靠性 2. avail ...
- Java--Eclipse关联Java源码
打开Eclipse,Window->Preferences->Java 点Edit按钮后弹出: 点Source Attachment后弹出: 选择Java安装路径下的src.zip文件即可 ...
- ORACLE11.2.0 SQLPLUS 报 error while loading shared libraries
相应的环境平台: OS: Linux TEST11G 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux ...
- 环保创业的可行之道——Leo鉴书上66
近2年,我一直在关注不同企业的发展历程,国内的国外的.看他们成功其中的共性与特性.<蚯蚓创业记>无疑给我开了扇窗--环保企业的怎样发展与壮大.读者还能从书里读出普通年轻人坚持自己梦想最终得 ...
- tq2440+fedora安装qt4.5
1. make[1]: arm-none-linux-gnueabi-g++:命令未找到 make[1]: *** [.obj/release-shared-emb-arm/qatomic_arm.o ...
- 我的mysql数据库sql优化原则
原文 我的mysql数据库sql优化原则 一.前提 这里的原则 只是针对mysql数据库,其他的数据库 某些是殊途同归,某些还是存在差异.我总结的也是mysql普遍的规则,对于某些特殊情况得特殊对待. ...
- uva 568(数学)
题解:从1開始乘到n,由于结果仅仅要最后一位.所以每乘完一次,仅仅要保留后5位(少了值会不准确,刚開始仅仅保留了一位.结果到15就错了,保留多了int会溢出,比方3125就会出错) 和下一个数相乘,接 ...