E. Bus Number(Permutations and Combinations)
发布时间
阅读量:
阅读量
E. Bus Number
题解:
针对多重集的问题,首先需要列举出所有可能的排列方式,即不考虑前导零的情况下的总方案数。随后,通过将一个零固定于起始位置,其余零则可在剩余位置中任意插入,计算出这种特定情况下的方案数量。最终将这一数值从总的方案数中扣除,即可得到符合要求的答案。
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
int num[10],tempNum[10],a[10];
ll jc[20],ans=0;
void dfs(int x)
{
if(x==10){
int now=1,cnt=0,tmp=0;
for(int i=0;i<10;i++) {
cnt+=tempNum[i];
now=now*jc[tempNum[i]];
}
now=jc[cnt]/now;
if(tempNum[0]>=1){
tmp=jc[cnt-1];
tmp/=jc[tempN
全部评论 (0)
还没有任何评论哟~
