A - Happy Birthday, Polycarp!
1 second
256 megabytes
standard input
standard output
Hooray! Polycarp turned nn years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his nn birthdays: from the 11-th to the nn-th. At the moment, he is wondering: how many times he turned beautiful number of years?
According to Polycarp, a positive integer is beautiful if it consists of only one digit repeated one or more times. For example, the following numbers are beautiful: 11, 7777, 777777, 4444 and 999999999999. The following numbers are not beautiful: 1212, 1111011110, 69696969 and 987654321987654321.
Of course, Polycarpus uses the decimal numeral system (i.e. radix is 10).
Help Polycarpus to find the number of numbers from 11 to nn (inclusive) that are beautiful.
The first line contains an integer tt (1≤t≤1041≤t≤104) — the number of test cases in the input. Then tt test cases follow.
Each test case consists of one line, which contains a positive integer nn (1≤n≤1091≤n≤109) — how many years Polycarp has turned.
Print tt integers — the answers to the given test cases in the order they are written in the test. Each answer is an integer: the number of beautiful years between 11 and nn, inclusive.
Example
6
18
1
9
100500
33
1000000000
output
10
1
9
45
12
81
题目地址:https://codeforces.com/contest/1277/problem/A
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int t,n;
int z[10]={0,1,2,3,4,5,6,7,8,9};
int b[15];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int ans=0;
for(int i=1;i<=9;i++){
long long int x=i;
while(x<=n)//枚举iii…i<=n
{
ans++;
x=10*x+i;
}
}
printf("%d\n",ans);
}
return 0;
}
A - Happy Birthday, Polycarp!的更多相关文章
- cf723c Polycarp at the Radio
		
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...
 - codeforces 723C : Polycarp at the Radio
		
Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...
 - Codeforces 723C. Polycarp at the Radio 模拟
		
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
 - Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心
		
C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
 - Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集
		
题目链接: 题目 F. Polycarp and Hay time limit per test: 4 seconds memory limit per test: 512 megabytes inp ...
 - Polycarp's problems
		
Polycarp's problems time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
 - Codeforce B. Polycarp and Letters
		
B. Polycarp and Letters time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
 - [Codeforces 864B]Polycarp and Letters
		
Description Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s con ...
 - 贪心 C - Polycarp's New Job
		
Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even sto ...
 - Codeforces 861D - Polycarp's phone book
		
861D - Polycarp's phone book 思路:用map做的话,只能出现一次循环,否则会超时. 代码: #include<bits/stdc++.h> using name ...
 
随机推荐
- 2019-7-01 python基础数据类型
			
一.python的注释 python的注释分类: 单行注释: # 单行注释 多行注释:(可以是三个单也可以是三个双) ''' 单三引号多行注释 ''' """ 双 ...
 - 玩机之Honor_V10
			
作为一个热爱手机的Geek,自然是经历了很多的刷机和改装手机的经验,当然翻车的经验也是有的.一般来说的折腾手机都是在遇到某一版本使用以及各方面都比较稳定的时候才会选择让手机停留在哪一版本.下面我就来分 ...
 - Ideaui和WebStrom2019最新版自动生成破解码
			
http://idea.medeming.com/jet/ 直接点击下载 6ZUMD7WWWU-eyJsaWNlbnNlSWQiOiI2WlVNRDdXV1dVIiwibGljZW5zZWVOYW1l ...
 - CentOS7 安装 Docker、最佳Docker学习文档
			
目录 一.Docker支持 二.安装Docker -1.在新主机上首次安装Docker CE之前,需要设置Docker存储库.之后,就可以从存储库安装和更新Docker. 0.卸载旧版 1.正式安装 ...
 - C# vb .net实现像素化效果滤镜打马赛克
			
在.net中,如何简单快捷地实现Photoshop滤镜组中的像素化效果打马赛克呢?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码: 设置授 ...
 - sqlserver 2005 数据库的差异备份与还原
			
找到一个可靠的步骤,点开链接:http://blog.csdn.net/kevindr/article/details/22154323
 - IEnumerable,ICollection,IList,List的使用
			
做C#的都知道:一类只能有一个继承类,但可以实现多个接口.这句话就告诉我们:IEnumerable,ICollection,IList,List区别了 首先我看看 IEnumerable: // ...
 - NEST 自定义分析器
			
public void SetAnalysis() { if (!client.IndexExists("employee").Exists) { client.CreateInd ...
 - 小程序加入echart 图表
			
github上的地址 https://github.com/ecomfe/echarts-for-weixin 复制到当前项目根目录下 添加展示bar图表例子的文件夹 index.json 中配置使用 ...
 - python基础知识和练习代码
			
1.编译:将高级语言源代码转换成目标代码(机器语言),程序便可运行.  好处:目标代码执行速度更快:目标代码在相同操作系统上使用灵活. 2.解释:将高级语言源代码逐条转换成目标代码同时逐条执行,每次 ...