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; ...
随机推荐
- 凤凰OS
看看这个http://www.phoenixos.com 是不是你想要的 --- 共有 5 条评论 --- Entity回复 @Leaybc : 今天装的凤凰os,有很多的BUG整天还不错. ...
- 每周日与周四《红酒屋》探戈舞会"Wine Bar" Milonga_原生态拉丁_新浪博客
每周日与周四<红酒屋>探戈舞会"Wine Bar" Milonga_原生态拉丁_新浪博客 每周日与周四<红酒屋>探戈舞会"Wine Bar ...
- CSS中position详解与常见应用实现
在web前台开发时候,我们必不可少的会用到postion属性进行布局定位.今天总结了一下position知识点,与常用功能与大家分享,欢迎大家交流指正. 首先我们对postion属性进行详解. 在CS ...
- 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序
原文 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序 Jim ...
- Git 在小团队中的管理流程(转)
目标读者:了解 Git 的基本概念,能够使用 Git 进行基本的本地和远程操作. 有关 Git 的基础知识可以参见 知乎回答-怎样使用 GitHub?,天猪(刘勇)给出了一些很好的学习资料. 本文介绍 ...
- MFC画二维动态图表[GDI]
源博客:http://www.codeproject.com/Articles/9350/2D-Animated-Charts 源代码:http://download.csdn.net/detail/ ...
- 九度OnlineJudge之1020:最小长方形
题目描述: 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. 输入: ...
- 测试framebuffer
static GGLContext *gr_context = 0; static GGLSurface gr_framebuffer[2]; static unsigned gr_active_fb ...
- AES加密例子(python和php版本)
AES加密例子(python和php版本) AES加密例子(python和php版本)
- 【Cocos2d-X游戏实战开发】捕鱼达人之开发前准备工作(一)
本系列学习教程使用的是cocos2d-x-2.1.4(最新版为cocos2d-x-2.1.5) 博主发现前两个系列的学习教程被严重抄袭,在这里呼吁大家请尊重开发者的劳动成果, 转载的时候请务必注明出处 ...