我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. Spring Authorization Server 0.3.0 发布,官方文档正式上线

    基于OAuth2.1的授权服务器Spring Authorization Server 0.3.0今天正式发布,在本次更新中有几大亮点. 文档正式上线 Spring Authorization Ser ...

  2. python封装发送邮件类

    import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart i ...

  3. Spring Authorization Server(AS)从 Mysql 中读取客户端、用户

    Spring AS 持久化 jdk version: 17 spring boot version: 2.7.0 spring authorization server:0.3.0 mysql ver ...

  4. Linux版本的项目环境搭建

    项目环境docker及docker-compose文档 1.Linux环境介绍 centos7.6 16G以上内存空间(至少8G) 2.静态IP设置 1.找到配置文件 cd /etc/sysconfi ...

  5. django框架3

    内容概要 注册登录功能编写 django请求生命周期流程图 路由层相关知识 1.路由匹配 2.无名有名分组 3.反向解析 4.名称空间 5.路由分发 内容详情 注册登录功能编写 1.使用自带的sqli ...

  6. GDKOI 2021 Day2 PJ 去世记

    比赛时和昨天一样困,后面的大奆打代码的速度简直了 T1 用 2.4.6.8 来与 5 抵消掉末尾的 0 ,然后用周期问题的方法直接乘起来并取个位 #include<bits/stdc++.h&g ...

  7. CAP 6.1 版本发布通告

    前言 今天,我们很高兴宣布 CAP 发布 6.1 版本正式版,在这个版本中我们主要针对目前已经发现的几个BUG进行了修复了以及添加了一些小特性. 那么,接下来我们具体看一下吧. 总览 可能有些人还不知 ...

  8. Bika LIMS 开源LIMS集—— SENAITE的安装

    安装环境 操作系统 Ubuntu 18.04 LTS Python 2.x. Plone 4 安装步骤 Ubuntu等Linux.Mac系统一般安装有Python的环境,但由于需要安装Python扩展 ...

  9. KVM虚拟机安装及桥接网络配置

    1.查看CPU是否支持intel或AMD的虚拟技术 cat /proc/cpuinfo | grep -E "vmx|svm" --color --vmx intel的CPU sv ...

  10. Mysql安装配置以及解决重装Mysql时忘记root password问题

    目录 1.Mysql安装以及环境变量配置 重装Mysql时忘记root password问题 1.Mysql安装以及环境变量配置 官网安装:​​​​​​https://www.mysql.com/ 按 ...