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 ...
- 同一个form里,不管哪个 submit 都是直接提交form表单里的内容
要达到你的目的,就不能用类型为 submit 的按钮,要用 button,然后加onclick 方法来自定义预处理参数,然后再调用 submit 方法提交表单,比如 <script type=& ...
- php使用 _before_index() 来实现访问页面前,判断登录
C:\wamp\www\DEVOPS\Home\Lib\Action: <?php class IndexAction extends Action { function index(){ $t ...
- Fedora 17 下安装codeblocks
Fedora 17 下安装codeblocks: 1.直接从yum源安装: sudo yum install codeblocks 2.源码安装 ...
- 【Demo 0006】Android 组件(Activity)
本章学习要点: 1. 了解Activity基本概念; 2. 掌握Activity生命周期: 3. 掌握 Activity之间跳转:
- jquery如何在加载完iframe的内容后才进行下一步操作
为iframe添加onload事件 ie使用attachEvent("onload",function(){}) firefox.chrome使用addEventListener( ...
- Swift教程之typealias代替OC的typedef
//MARK:-------swift中的typedef-------------- //使用 keyword定义类型别名,相似typedef typealias NSInteger = Int va ...
- 创建采购订单批到程序用的BAPI
CALL FUNCTION 'BAPI_PO_CREATE1' EXPORTING poheader = poheader poheaderx = poheaderx * POADDRVENDOR = ...
- 使用JDBC对数据库实现批处理操作
本篇讲述如何使用JDBC对数据库实现批处理操作.很多时候单条SQL命令不能满足我们的需求,我们需要对数据库一次实现很多操作,需要发送一批SQL命令给数据库执行. 而JDBC也提供了相应的方法给我们实现 ...
- v$lock 视图访问慢解决方法
V$ 视图访问慢 --解决方法 分析:可能是有数据字典统计信息过久,造成. exec dbms_stats.gather_fixed_objects_stats; ------收集所有数据字典的fix ...