http://acm.hdu.edu.cn/showproblem.php?pid=4535

错排公式:a[i]=(i-1)*(a[i-2]+a[i-1]);

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define maxn 10000
using namespace std;
const ll mod=+; int t;
int n;
ll a[maxn]; int main()
{
scanf("%d",&t);
a[]=; a[]=;
for(int i=; i<=; i++)
{
a[i]=((i-)*(a[i-]+a[i-]))%mod;
}
while(t--)
{
scanf("%d",&n);
printf("%lld\n",a[n]);
}
return ;
}

hdu 4535 吉哥系列故事——礼尚往来的更多相关文章

  1. HDU 4535 吉哥系列故事——礼尚往来( 错排水题 )

    链接:传送门 思路:错排模板题,水题是非常浪费时间的. /*********************************************************************** ...

  2. HDU1465 不容易系列之一&&HDU4535吉哥系列故事——礼尚往来

    HDU1465不容易系列之一 Problem Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加 ...

  3. hdu 4512 吉哥系列故事——完美队形I【LCIS经典应用】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=4512 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  4. HDU 4513 吉哥系列故事――完美队形II(Manacher)

    题目链接:cid=70325#problem/V">[kuangbin带你飞]专题十六 KMP & 扩展KMP & Manacher V - 吉哥系列故事――完美队形I ...

  5. HDU 4513 吉哥系列故事――完美队形II

    http://acm.hdu.edu.cn/showproblem.php?pid=4513 吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) ...

  6. HDU 4513 吉哥系列故事——完美队形II manacher

    吉哥系列故事——完美队形II Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希 ...

  7. hdu 4513 吉哥系列故事——完美队形II (manachar算法)

    吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) P ...

  8. HDU 4512——吉哥系列故事——完美队形I——————【LCIS应用】

    吉哥系列故事——完美队形I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

  9. HDU 4513 吉哥系列故事——完美队形II(Manacher)

    Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成 ...

随机推荐

  1. 线段树解Insertion Sort Advanced Analysis

    题目出处 题意描述: 这个题目提问的是,在插入排序的序列给定的情况下,求最少需要移动的次数. 序列的长度n <=10^5 序列中的元素a[i] <=10^6 一组数据中case数t < ...

  2. openStack Use Orchestration module(heat) create and manage cloud resources

  3. C#中枚举类型和int类型的转化

    先定义一个枚举类型 , 初中, 高中,大学 }; int ->enum int d=2; PropertyType  a=(PropertyType)d; int <- enum Prop ...

  4. DTN学习的一些有用链接

    1.DTN研究组,该网站提供了一些代码,有NS2上的实现,也有用java实现的源码. http://www.dtnrg.org/wiki/Code 2.DTN实现的另一个版本,与ONE比较,目前还没用 ...

  5. poj 3046 Ant Counting (DP多重背包变形)

    题目:http://poj.org/problem?id=3046 思路: dp [i] [j] :=前i种 构成个数为j的方法数. #include <cstdio> #include ...

  6. Scala学习笔记之:tuple、array、Map

    [TOC] 本文<快学Scala>的笔记 tuple学习笔记 tuple的定义 对偶是元组(tuple)的最简单形态--元组是不同类型的值的聚集. 元组的值是通过将单个值包含在圆括号中构成 ...

  7. Android进程机制

    以下资料摘录整理自老罗的Android之旅博客,是对老罗的博客关于Android底层原理的一个抽象的知识概括总结(如有错误欢迎指出)(侵删):http://blog.csdn.net/luosheng ...

  8. Virtualbox安装增强工具失败

    在安装Virtualbox增强工具安装时出现unable to find the sources of your current Linux kernel,安装失败,导致主机与虚拟机之间不能共享文件夹 ...

  9. 一条insert语句批量插入多条记录

    一条insert语句批量插入多条记录 常见的insert语句,向数据库中,一条语句只能插入一条数据: insert into persons (id_p, lastname , firstName,  ...

  10. 如何在github上传自己的项目

    1.首先在github创建自己的账号. 2.下载github for windows 客户端 (备注:这里我的电脑是windows系统的) ,不要下载错了,网上下载的应该是这样的安装程序 3.安装gi ...