网站搜索优化价格,淮南教育网官网,大气的网站设计,公司起名字大全免费2023https://www.lydsy.com/JudgeOnline/problem.php?id2425 https://www.luogu.org/problemnew/show/P2518 你有一组非零数字#xff08;不一定唯一#xff09;#xff0c;你可以在其中插入任意个0#xff0c;这样就可以产生无限个数。比如说给定{1,2},那么可以生成数字12,21…https://www.lydsy.com/JudgeOnline/problem.php?id2425 https://www.luogu.org/problemnew/show/P2518 你有一组非零数字不一定唯一你可以在其中插入任意个0这样就可以产生无限个数。比如说给定{1,2},那么可以生成数字12,21,102,120,201,210,1002,1020,等等。 现在给定一个数问在这个数之前有多少个数。注意这个数不会有前导0. 题意看了半天终于看懂了。 我们从高位到低位枚举比当前位小的数然后对于剩下的元素放在后面全排列即可。 可重元素全排列元素个数/每个元素个数的乘积。 防止爆ll可以将分子分母分解后约分再计算。 貌似本质上是一道很暴力有点思维的水题不是数位dp #includecstdio
#includeiostream
#includevector
#includequeue
#includecstring
#includealgorithm
using namespace std;
typedef long long ll;
const int N51;
inline int read(){int X0,w0;char ch0;while(!isdigit(ch)){w|ch-;chgetchar();}while(isdigit(ch))X(X3)(X1)(ch^48),chgetchar();return w?-X:X;
}
char s[N];
int n,sum,t[11],p[N];
ll ans0;
int main(){cins1;nstrlen(s1);for(int i1;in;i)t[s[i]-0],sum;for(int i1;in;i){for(int j0;js[i]-0;j){if(t[j]){memset(p,0,sizeof(p));t[j]--;sum--;for(int k0;k9;k)for(int l2;lt[k];l)p[l];ll tmp1;for(int k2;ksum;k){tmp*k;for(int l2;lN;l){while(p[l]tmp%l0){p[l]--;tmp/l;}}}anstmp;t[j];sum;}}t[s[i]-0]--,sum--;}printf(%lld\n,ans);return 0;
} 本文作者luyouqi233。 欢迎访问我的博客http://www.cnblogs.com/luyouqi233/ 转载于:https://www.cnblogs.com/luyouqi233/p/8970411.html