我bingoyes再高精用STL就饿死,死外边!


string真的爽。。。

斯特林数模板题:\(S(n,m) = S(n-1,m-1)+S(n-1,m)*n\)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define R(a,b,c) for(register int a = (b); a <= (c); ++ a)
#define nR(a,b,c) for(register int a = (b); a >= (c); -- a)
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Fill(a,b) memset(a, b, sizeof(a))
#define Abs(a) ((a) < 0 ? -(a) : (a))
#define Swap(a,b) a^=b^=a^=b
#define ll long long #define ON_DEBUG #ifdef ON_DEBUG #define D_e_Line printf("\n\n----------\n\n")
#define D_e(x) cout << #x << " = " << x << endl
#define Pause() system("pause")
#define FileOpen() freopen("inn.txt","r",stdin); #else #define D_e_Line ;
#define D_e(x) ;
#define Pause() ;
#define FileOpen() ; #endif struct ios{
template<typename ATP>ios& operator >> (ATP &x){
x = 0; int f = 1; char c;
for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
x*= f;
return *this;
}
}io;
using namespace std; const int N = 1007; int a[N], b[N];
string add(string A, string B){
string S;
Fill(a, 0), Fill(b, 0);
int lenA = A.size(), lenB = B.size();
R(i,0,lenA - 1) a[i] = A[lenA - i - 1] ^ '0';
R(i,0,lenB - 1) b[i] = B[lenB - i - 1] ^ '0';
int len = Max(lenA, lenB);
R(i,0,len - 1){
a[i] += b[i];
a[i + 1] += a[i] / 10;
a[i] %= 10;
}
if(a[len]) ++len;
nR(i,len - 1,0) S += a[i] + '0';
return S;
} string mul(string A, int B){
string S;
int len = A.size();
Fill(a, 0);
R(i,0,len - 1) a[i] = A[len - i - 1] ^ '0';
int res = 0;
R(i,0,len - 1){
a[i] = a[i] * B + res;
res = a[i] / 10;
a[i] = a[i] % 10;
}
while(res){
a[len++] = res % 10;
res /= 10;
}
nR(i,len - 1, 0) S += a[i] + '0';
return S;
}
string f[107][107];
int n, m;
int main(){
//FileOpen(); R(i,1,100)
f[i][1] = "1";
R(i,2,100){
R(j,1,i){
f[i][j] = add(f[i - 1][j - 1], mul(f[i - 1][j], j));
}
}
while(~scanf("%d%d", &n, &m)){
if(n < m)
printf("0\n");
else
cout << f[n][m] << "\n";
} return 0;
}

Luogu1655 小朋友的球 (组合数学,第二类斯特林数,高精)的更多相关文章

  1. Gym - 101147G G - The Galactic Olympics —— 组合数学 - 第二类斯特林数

    题目链接:http://codeforces.com/gym/101147/problem/G G. The Galactic Olympics time limit per test 2.0 s m ...

  2. BZOJ 2159: Crash 的文明世界(组合数学+第二类斯特林数+树形dp)

    传送门 解题思路 比较有意思的一道数学题.首先\(n*k^2\)的做法比较好想,就是维护一个\(x^i\)这种东西,然后转移的时候用二项式定理拆开转移.然后有一个比较有意思的结论就是把求\(x^i\) ...

  3. 【BZOJ5093】图的价值(第二类斯特林数,组合数学,NTT)

    [BZOJ5093]图的价值(第二类斯特林数,组合数学,NTT) 题面 BZOJ 题解 单独考虑每一个点的贡献: 因为不知道它连了几条边,所以枚举一下 \[\sum_{i=0}^{n-1}C_{n-1 ...

  4. 【BZOJ4555】求和(第二类斯特林数,组合数学,NTT)

    [BZOJ4555]求和(第二类斯特林数,组合数学,NTT) 题面 BZOJ 题解 推推柿子 \[\sum_{i=0}^n\sum_{j=0}^iS(i,j)·j!·2^j\] \[=\sum_{i= ...

  5. Codeforces 932 E Team Work ( 第二类斯特林数、下降阶乘幂、组合数学 )

    题目链接 题意 : 其实就是要求 分析 : 先暴力将次方通过第二类斯特林数转化成下降幂 ( 套路?) 然后再一步步化简.使得最外层和 N 有关的 ∑ 划掉 这里有个技巧就是 将组合数的表达式放到一边. ...

  6. 8-机器分配(hud4045-组合+第二类斯特林数)

    http://acm.hdu.edu.cn/showproblem.php?pid=4045 Machine schedulingTime Limit: 5000/2000 MS (Java/Othe ...

  7. 【CF932E】Team Work(第二类斯特林数)

    [CF932E]Team Work(第二类斯特林数) 题面 洛谷 CF 求\(\sum_{i=1}^nC_{n}^i*i^k\) 题解 寒假的时候被带飞,这题被带着写了一遍.事实上并不难,我们来颓柿子 ...

  8. HDU2643(SummerTrainingDay05-P 第二类斯特林数)

    Rank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  9. Codeforces Round #100 E. New Year Garland (第二类斯特林数+dp)

    题目链接: http://codeforces.com/problemset/problem/140/E 题意: 圣诞树上挂彩球,要求从上到下挂\(n\)层彩球.已知有\(m\)种颜色的球,球的数量不 ...

  10. 国家集训队 Crash 的文明世界(第二类斯特林数+换根dp)

    题意 ​ 题目链接:https://www.luogu.org/problem/P4827 ​ 给定一棵 \(n\) 个节点的树和一个常数 \(k\) ,对于树上的每一个节点 \(i\) ,求出 \( ...

随机推荐

  1. 【Java面试】如何理解Spring Boot中的Starter?

    一个工作了3年的Java程序员,遇到一个Spring Boot的问题. 他对这个问题有一些了解,但是回答得不是很好,希望参考我的高手回答. 这个问题是:"如何理解Spring Boot中的S ...

  2. 「JOISC 2020 Day1」汉堡肉

    我终于学会打开机房的LOJ了! description LOJ3272 有\(n(n<=2*10^5)\)个矩形,让你找\(k(k<=4)\)个点可以覆盖所有矩形(点可重复),输出一种方案 ...

  3. 从零开始实现lmax-Disruptor队列(一)RingBuffer与单生产者、单消费者工作原理解析

    1.lmax-Disruptor队列介绍 disruptor是英国著名的金融交易所lmax旗下技术团队开发的一款java实现的高性能内存队列框架 其发明disruptor的主要目的是为了改进传统的内存 ...

  4. 离线环境使用NuGet

    更新记录 本文迁移自Panda666原博客,原发布时间:2021年5月13日. 在Visual Studio中直接使用GUI的方式操作NuGet包非常的方便.如果喜欢命令行,也可以使用包管理控制台或者 ...

  5. SQL Server 2008~2019版本序列号/密钥/激活码 汇总

    SQL Server 2019 Enterprise:HMWJ3-KY3J2-NMVD7-KG4JR-X2G8G Strandard:PMBDC-FXVM3-T777P-N4FY8-PKFF4 SQL ...

  6. 在sqlbolt上学习SQL

    在sqlbolt上学习SQL 该网站能够学习sql基础,并且能在网页中直接输入sql语句进行查询. 学习网站原网址https://sqlbolt.com/(!部分指令该网站不支持,且存在一些bug!) ...

  7. 从Mpx资源构建优化看splitChunks代码分割

    背景 MPX是滴滴出品的一款增强型小程序跨端框架,其核心是对原生小程序功能的增强.具体的使用不是本文讨论的范畴,想了解更多可以去官网了解更多. 回到正题,使用MPX开发小程序有一段时间了,该框架对不同 ...

  8. Golang仿云盘项目-2.2 保留文件元信息

    本文来自博客园,作者:Jayvee,转载请注明原文链接:https://www.cnblogs.com/cenjw/p/16459817.html 目录结构 E:\goproj\FileStorage ...

  9. springboot集成redis集群

    1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  10. 牛客SQL刷题第三趴——SQL必知必会

    01检索数据 SQL60 从 Customers 表中检索所有的 ID 编写 SQL 语句,从 Customers 表中检索所有的cust_id select * from Customers; SQ ...