题目链接:https://vjudge.net/problem/Gym-101243H 题意:给你一个数n,让你求有多少个不同的n位数,而且从左往右数第i位不能为i,其实不能有前导零 解析:其实就是个排列组合的问题吧,第一位只能放8个数,第二位一直到第9位能放9位数,其他可以放10位数,直接输出即可
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
const int maxn =
1e5+
100;
const int mod =
1e9+
7;
int main()
{
freopen(
"input.txt",
"r",stdin);
freopen(
"output.txt",
"w",stdout);
int n;
scanf(
"%d",&n);
long long ans =
8;
if(n<=
9)
{
for(
int i=
1;i<n;i++)
ans *=
9;
printf(
"%I64d\n",ans);
}
else
{
printf(
"344373768");
for(
int i=
0;i<n-
9;i++)
printf(
"0");
puts(
"");
}
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-20350.html