Repeat Number
来源:互联网 发布:足球网站关注软件 编辑:程序博客网 时间:2024/06/04 23:18
Repeat Number
时间限制: 1 Sec 内存限制: 128 MB提交: 28 解决: 9
[提交][状态][论坛]
题目描述
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
先求出所有 11 22...到1111111所有的repeat number取值,然后就好办了。
AC代码:
#include<iostream>using namespace std;int a[60],t;void init(){ int k; t=0; k=1; for(int i=0;i<5;i++){ k=k*10+1; for(int j=1;j<=9;j++) a[t++]=k*j; } a[t++]=1111111;}int main(){ init(); int x,y; while(cin>>x>>y){ int i,p,q; for(i=0;i<t;i++) if(a[i]>=2*x){ q=i; break; } if(i==t){ cout<<0<<endl; continue; } for(i=t-1;i>=0;i--) if(a[i]<=2*y){ p=i; break; } if(i==-1){ cout<<0<<endl; continue; } int sum=0; for(i=q;i<=p;i++){ if(a[i]&1){ if(a[i]/2-x<y-a[i]/2) sum+=a[i]/2-x+1; else sum+=y-a[i]/2; } else{ if(a[i]/2-x<y-a[i]/2) sum+=a[i]/2-x+1; else sum+=y-a[i]/2+1; } } cout<<sum<<endl; } return 0;}
0 0
- Repeat Number
- Repeat Number
- Repeat Number
- ZCMU-1445-Repeat Number
- 1445: Repeat Number
- 2014辽宁省赛 Repeat Number
- kuangbin群赛-1002-Repeat Number
- repeat
- Algorithm-Arrays-5 Repeat and Missing Number Array
- Repeat Part of the Regex a Certain Number of Times (重复匹配中的部分)
- background-repeat:no-repeat
- Finding a number that repeats even no of times where all the other numbers repeat odd no of times
- Repeat分页
- selective repeat
- background-repeat
- repeat嵌套
- repeat until
- Angularjs repeat
- Iframe使用小结
- [几何]D
- android 应用程序退出代码实现
- C++学习第二、第三天
- SAE安装第三方插件
- Repeat Number
- 策略模式Strategy——回家乘什么车?
- maven学习笔记(一)--环境搭建
- 【c/c++ 算法/数据结构】 邻接矩阵表示图,深度,广度优先遍历 算法设计+代码+图片
- @autoreleasepool学习记录
- WTL界面自绘系列-预备
- 损失函数(loss function)
- Sapphire手机按钮检测控件Sapphire Buttons Utility详细介绍
- nodejs 批处理执行 app.js