non-random numbers
来源:互联网 发布:慢慢买数据怎么看 编辑:程序博客网 时间:2024/06/05 01:51
Vasya is a schoolboy who was playing around with a random number generator and
noticed that it never generates numbers with the value of a specific digit equal to the
position of that digit in the number.
Vasya became curious and he came to discover the following:
? The input accepted by the generator is one positive integer n – the
number of digits in the generated random number.
? The output is a positive integer number consisting of n digits without
leading zeroes.
? In the generated number at i position (from the left-hand side) cannot be
digit i.
For example, if we want the generator to produce a single-digit number, it will
generate any single-digit number except 0 or 1. In case with a double-digit number,
the output will be anything except 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 32, 42,
52, 62, 72, 82 or 92.
The schoolboy decided to find out how many different numbers can be generated for
any given n-digit number.
Your task is to write a program that will help the schoolboy to solve this problem.
Limitations
1 ≤ n ≤ 100.
Input
The input file contains single integer n – the number of digits in the generated
random number.
Output
The output file must contain one single integer – the number of possible random n-
digit numbers. The output must have no leading zeroes.
Examples
Input.txt Output.txt
1 8
2 72
noticed that it never generates numbers with the value of a specific digit equal to the
position of that digit in the number.
Vasya became curious and he came to discover the following:
? The input accepted by the generator is one positive integer n – the
number of digits in the generated random number.
? The output is a positive integer number consisting of n digits without
leading zeroes.
? In the generated number at i position (from the left-hand side) cannot be
digit i.
For example, if we want the generator to produce a single-digit number, it will
generate any single-digit number except 0 or 1. In case with a double-digit number,
the output will be anything except 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 32, 42,
52, 62, 72, 82 or 92.
The schoolboy decided to find out how many different numbers can be generated for
any given n-digit number.
Your task is to write a program that will help the schoolboy to solve this problem.
Limitations
1 ≤ n ≤ 100.
Input
The input file contains single integer n – the number of digits in the generated
random number.
Output
The output file must contain one single integer – the number of possible random n-
digit numbers. The output must have no leading zeroes.
Examples
Input.txt Output.txt
1 8
2 72
12 344373768000
问n位数中第x位不等于x的数的个数
思路:
当n前10时直接相乘
例如8*9*9*9*9....
当n大于9时直接乘10直接加0就可以了
ac代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); long long x; long long y; while(scanf("%lld",&y)!=-1) { if(y<10) { x=8; for(int i=1;i<y;i++) x=x*9; printf("%lld\n",x); } else { printf("344373768"); for(int i=1;i<=y-9;i++) printf("0"); printf("\n"); } } return 0;}
0 0
- Non-random numbers
- non-random numbers
- Non--Abundant numbers
- BZOJ2986 Non-Squarefree Numbers
- Random Numbers in Linux
- HGE:Tutorials:Random Numbers
- 350 - Pseudo-Random Numbers
- Thread-Safe Random Numbers
- 350 - Pseudo-Random Numbers
- 350 - Pseudo-Random Numbers
- Pseudo-Random Numbers
- UVa350 Pseudo-Random Numbers
- Pseudo-Random Numbers
- Pseudo-Random Numbers UVA350
- 350 - Pseudo-Random Numbers
- uva350 - Pseudo-Random Numbers
- UVA350 Pseudo-Random Numbers
- UVA Pseudo-Random Numbers
- unix/linux ls命令的实现
- JZOJ 3637. 【COCI2013】linije
- Eclipse JSP/Servlet 环境搭建
- python系列整理列表
- 高精度板( 无除法、减法 )
- non-random numbers
- 使用HTML标签
- ArcGIS面简化工具的BUG
- 欧氏距离和余弦相似度
- Hibernate读取配置文件,创建sessionFactory的执行过程以及用工具类优化
- Android Fragment 真正的完全解析(下)
- HTML5+原生javascript 卡片扑克旋转展开效果demo
- springmvc整合mybatis框架源码 bootstrap html5 mysql oracle maven SSM
- Linux ftp命令的使用