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. pip常用命令

    以flask为例. 1. 安装 # pip install flask 安装 flask. # pip install flask==1.0 安装 1.0版本的flask # pip install ...

  2. (1.1.9)UVA 10930 A-Sequence(模拟)

    /* * UVA_10930_1.cpp * * Created on: 2013年10月7日 * Author: Administrator */ #include <iostream> ...

  3. Oracle sqlplus 语法

    目录: 0. FREFACE 1. 执行一个SQL脚本文件 2. 对当前的输入进行编辑 3. 重新运行上一次运行的sql语句 4. 将显示的内容输出到指定文件 5. 关闭spool输出 6.显示一个表 ...

  4. ZOJ1221 && UVA567:Risk(Floyd)

    Risk is a board game in which several opposing players attempt to conquer the world. The gameboard c ...

  5. springMVC之本地化和国际化

    spring框架的大部分都支持国际化,就像springMVC一样.DispatcherServlet使你能够动态的通过客户端的本地语言进行配置.这是通过LocaleResolver完成的.   当一个 ...

  6. motan源码分析三:与spring框架的结合

    在本文第一章,分析的demo中使用了代码加载的方式加载了相关的类,但在我们的实际工作中,使用spring来加载相关的类的情况会更多,本文将分析一下motan是如何与spring一起协同工作的,主要的原 ...

  7. SKPhysicsJointFixed类

    继承自 NSObject 符合 NSCoding(SKPhysicsJoint)NSObject(NSObject) 框架  /System/Library/Frameworks/SpriteKit. ...

  8. Genymotion 模拟器 VirtualBox

    准备 介绍: 1.Genymotion安卓模拟器其实不是普通的模拟器,严格来说,genymotion是虚拟机,被网传定义为模拟器,加载APP的速度比较快,操作起来也很流畅.2.Genymotion依赖 ...

  9. MyEclipse保存文件时 自动格式化代码! 不包括文档注释

    设置不格式化 文档注释

  10. Node.js脚本杀掉占用端口的进程

    express默认端口为3000,由于实际需要改为3392,修改监听3392之后,没有成功,发现该端口被系统正占用,为了避免每次都手工停掉该系统调用,释放端口,故写了如下脚本. var cmd=pro ...