链接:

https://vjudge.net/problem/LightOJ-1326

题意:

Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded and wandered around, even in their holidays. They passed several months in this way. But everything has an end. A holy person, Munsiji came into their life. Munsiji took them to derby (horse racing). Munsiji enjoyed the race, but as usual Disky and Sooma did their as usual task instead of passing some romantic moments. They were thinking- in how many ways a race can finish! Who knows, maybe this is their romance!

In a race there are n horses. You have to output the number of ways the race can finish. Note that, more than one horse may get the same position. For example, 2 horses can finish in 3 ways.

  1.  Both first
  2.  horse1 first and horse2 second
  3.  horse2 first and horse1 second

思路:

Dp[i][j] 表示一共i匹马,分成j批冲线。

Dp[i][j] = Dp[i-1][j]j+Dp[i-1][j-1]j

代码:

// #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string.h>
#include<set>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int MOD = 10056;
const int MAXN = 1e6+10; int Dp[1010][1010];
int n; void Init()
{
Dp[0][0] = 1;
for (int i = 1;i <= 1000;i++)
{
for (int j = 1;j <= i;j++)
Dp[i][j] = (Dp[i-1][j-1]*j%MOD + Dp[i-1][j]*j%MOD)%MOD;
}
} int main()
{
// freopen("test.in", "r", stdin);
Init();
int t, cas = 0;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
printf("Case %d:", ++cas);
int ans = 0;
for (int i = 1;i <= n;i++)
ans = (ans+Dp[n][i])%MOD;
printf(" %d\n", ans);
} return 0;
}

LightOJ - 1326 - Race(DP)的更多相关文章

  1. lightOJ 1326 Race(第二类Stirling数)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1326 题意:有n匹马赛跑.问有多少种不同的排名结果.可以有多匹马的排名相同. 思路:排 ...

  2. LightOJ 1326 – Race 第二类Stirling数/

    简单的模板题. 题意:问n匹马出现的不同排名数. 题解:可以使用DP,本质上还是第二类Stirling数(隔板法) #include <stdio.h> #include <iost ...

  3. 周赛C题 LightOJ 1047 (DP)

    C - C Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Description Th ...

  4. LightOJ 1033 Generating Palindromes(dp)

    LightOJ 1033  Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  5. lightOJ 1047 Neighbor House (DP)

    lightOJ 1047   Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730# ...

  6. Lightoj 1038 - Race to 1 Again (概率DP)

    题目链接: Lightoj  1038 - Race to 1 Again 题目描述: 给出一个数D,每次可以选择数D的一个因子,用数D除上这个因子得到一个新的数D,为数D变为1的操作次数的期望为多少 ...

  7. hdu 4521 小明系列问题——小明序列(线段树 or DP)

    题目链接:hdu 4521 本是 dp 的变形,却能用线段树,感觉好强大. 由于 n 有 10^5,用普通的 dp,算法时间复杂度为 O(n2),肯定会超时.所以用线段树进行优化.线段树维护的是区间内 ...

  8. 蓝桥杯---地宫取宝(记忆搜索=搜索+dp)

    题目网址:http://lx.lanqiao.org/problem.page?gpid=T120 问题描述 X 国王有一个地宫宝库.是 n x m 个格子的矩阵.每个格子放一件宝贝.每个宝贝贴着价值 ...

  9. Travel(HDU 4284状压dp)

    题意:给n个城市m条路的网图,pp在城市1有一定的钱,想游览这n个城市(包括1),到达一个城市要一定的花费,可以在城市工作赚钱,但前提有工作证(得到有一定的花费),没工作证不能在该城市工作,但可以走, ...

随机推荐

  1. [转帖]超能课堂(207) SD卡标准错综复杂,到底该认哪一个?

    超能课堂(207)SD卡标准错综复杂,到底该认哪一个? https://www.expreview.com/71505.html 开始的地方 SD容量等级 SD标准(SDSC) SDHC SDXC S ...

  2. JSON.stringify()序列化的理解及使用

    该函数的作用是:系列化对象 系列化对象说白了就是把对象的类型转换为字符串类型 语法 JSON.stringify(value[, replacer [, space]]) value 将要序列化成 一 ...

  3. 「UER#2」信息的交换

    「UER#2」信息的交换 吉利题.. 不难发现,置换中的每一个循环是独立的,每一个循环分别对应一个独立的联通块. 根据题目的性质,每一个联通块做的事情等价于其按照编号从小到大遍历的的dfs生成树做的事 ...

  4. jquery跨js文件调用函数示例

    var common_func; (function() { common_func = { load_hot_data: function(AreaCode) { var hot_html = &q ...

  5. ADO.net(内置类区别)随记

    Ado.net使用流程 SqlConnection->open->SqlCommand(sqlstring,conn)->(ExcuteNonQuery \ExecuteScalar ...

  6. Angular—入门环境,项目创建,导入项目

    1.安装 nodejs,npm nodejs 下载地址: https://nodejs.org/en/download/

  7. 利用vba实现excel表格连接打印编号(一页两个编号),编号支持前缀

    先看一下excel文件, 下图左边部分为文件签审单为要打印的内容, 要求一页需要打印两个文件签审单, NO需要根据打印页面连续编号, 右边部分为打印设置,以及vba部分代码展示, 打印设置可以设置打印 ...

  8. ORACLE表、索引和分区详解

    ORACLE表.索引和分区 一.数据库表 每种类型的表都有不同的特性,分别应用与不同的领域 堆组织表 聚簇表(共三种) 索引组织表 嵌套表 临时表 外部表和对象表 1.行迁移 建表过程中可以指定以下两 ...

  9. vue辅助函数mapStates与mapGetters

    状态管理器 <!-- store.js: --> import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export de ...

  10. HttpClient实战三:Spring整合HttpClient连接池

    简介 在微服务架构或者REST API项目中,使用Spring管理Bean是很常见的,在项目中HttpClient使用的一种最常见方式就是:使用Spring容器XML配置方式代替Java编码方式进行H ...