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; ...
随机推荐
- Bootstrap "row"类宽度超过问题
问题原因: VOORBootstrap门格系统布局,类别col-xs-*身边有15px的padding,在这样的元素img我们希望展现的顶部边缘,这需要col-xs-*式:padding:0px; 如 ...
- codeforces #267 C George and Job(DP)
职务地址:http://codeforces.com/contest/467/problem/C 太弱了..这题当时都没做出来..思路是有的,可是自己出的几组数组总是过不去..今天又又一次写了一遍.才 ...
- 编译kernel:配置
韦东山Linux视频第1期_裸板_UBoot_文件系统_驱动初步\第10课第2节 内核启动流程分析之配置.WMV 下面以DM9000的配置为例: 在一个编译好的内核代码里,寻找CONFIG_DM900 ...
- ASIHTTPRequest-插件的使用
链接地址:http://blog.sina.com.cn/s/blog_7b9d64af0101e5uf.html 一.什么是ASIHTTPRequest ASIHTTPRequest 插件是一个 ...
- vim的ex模式用法
本文出自 http://blog.csdn.net/shuangde800 本文是在学习<使用vi编辑器, Lamb & Robbins编著>时在evernote写的其中一章笔 ...
- Swift - 经纬度位置坐标与真实地理位置相互转化
通过CoreLocation类,得到的定位信息都是以经度和纬度等表示的地理信息,通过CLGeocoder类可以将其反编码成一个地址.反之,也可根据一个地址获取经纬度. 1,通过经纬度获取地址 1 2 ...
- How to search a table in a store proc and open the store proc
1. select*fromdba_dependencieswherereferenced_name='CNTL_ISSUE'andTYPE='PROCEDURE' 2. selecttextfrom ...
- 六款常用的linux C/C++ IDE
摘要: 一.AnjutaAnjuta是一个多语言的IDE,它最大的特色是灵活,同时打开多个文件,内嵌代码级的调试器(调用gdb),应用程序向导(Application wizards)可以方便的帮助你 ...
- UVA 10160 Servicing Stations(深搜 + 剪枝)
Problem D: Servicing stations A company offers personal computers for sale in N towns (3 <= N < ...
- The Dole Queue
The Dole Queue Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit cid ...