我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. html5手册语义化标签

    html5手册语义化标签: article section aside hgroup header footer nav time mark figure figcaption contextmenu ...

  2. flink 流的合并

    flink 流的合并操作 union union只能合并类型相同的数据,合并的结果仍然是DataStream,结果操作与未合并之前一致. public static void main(String[ ...

  3. 七、服务器硬件及RAID配置实战

    一.RAID磁盘阵列介绍 磁盘阵列的全名(Redundant Arrays of Inexpensive Disk,RAID),中文简称是独立冗余磁盘阵列.冗余(如果磁盘出现故障,可以保证数据不丢) ...

  4. 能快速搭建三维场景,这款3D全场景编辑器你还没用过吗?

    今天就给大家分享一个非常好用的老子云3D全场景编辑器,不仅可以基于GIS数据,帮助用户快速搭建3D城市大场景.实现Web端流畅展示. 并且搭建的3D场景可离线开发成一个空间信息直观的.可交互.易于设计 ...

  5. Vue3.0系列——「vue3.0性能是如何变快的?」

    前言 先学习vue2.x,很多2.x内容依然保留: 先学习TypeScript,vue3.0是用TS重写的,想知其然知其所以然必须学习TS. 为什么学习vue3.0? 性能比vue2.x快1.2-2倍 ...

  6. C#/VB.NET 将PDF转为Excel

    PDF文档可以避免可防⽌他⼈⽆意中触到键盘修改⽂件内容.但是在避免他人⽆意修改的同时也妨碍了正常的修改.如果你想处理或修改PDF文档中的数据,不妨试试用Excel来实现.Excel拥有强大的数据处理功 ...

  7. key可重复的Map

    在正常的map操作中,key是不能重复的,如果希望key的内容可以重复,可以用IdentityHashMap 举个栗子 输出结果: public static void main(String[] a ...

  8. idea 查看 类所有方法的快捷键

    idea 查看 类 所有方法的快捷键 Idea:ctrl+F12 Eclipse:Ctrl+O

  9. NC25025 [USACO 2007 Nov G]Sunscreen

    NC25025 [USACO 2007 Nov G]Sunscreen 题目 题目描述 To avoid unsightly burns while tanning, each of the \(C\ ...

  10. Django WEB开发 - Django 3.0 Tutorial入门

    1. Django 官方网站 https://docs.djangoproject.com/zh-hans/3.0/intro/tutorial01/ 2. Model View Controller ...