0
点赞
收藏
分享

微信扫一扫

Gym - 101243H Non-random numbers【构造+数学】

是她丫 2022-11-23 阅读 67


题目链接:​​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;
}


举报

相关推荐

0 条评论