博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVALive 5971
阅读量:7028 次
发布时间:2019-06-28

本文共 1208 字,大约阅读时间需要 4 分钟。

Problem J Permutation Counting
Dexter considers a permutation of first N natural numbers good if it doesn't have x and x+1 appearing consecutively, where (1 ≤ x < N)  For example, for N=3 , all goodpermutations are:
1. {1, 3, 2}
2.{2, 1, 3}
3.{3, 2, 1}
Input
Input starts with an integer T (≤ 10000 , denoting the number of test cases.Each
case starts with a line containing an integer N (1 ≤ N ≤ 106)
.
Output
For each case, print the case number and the number ofgoodpermutations
modulo1000 000 007
.
Sample Input
Output for Sample Input
3
2
3
5
Case 1: 1
Case 2: 3
Case 3: 53
1 #include  2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #define LL long long19 #define PI 3.141592653589793262620 using namespace std;21 int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b);}22 #define MAXN 100000523 #define MOD 100000000724 LL ans[MAXN],tmp[MAXN];25 void init()26 {27 ans[1]=1;ans[2]=1;28 for (int i=3;i
View Code

 

 

转载地址:http://wdrxl.baihongyu.com/

你可能感兴趣的文章
渐进式Express源码学习5-全副武装
查看>>
JVM难学?那是因为你没认真看完这篇文章
查看>>
python面试题(五)
查看>>
老司机 iOS 周报 #40 | 2018-10-22
查看>>
VirtualView iOS 模板加载功能实现详解
查看>>
这可能是最好的性能优化教程(二)
查看>>
被马化腾点赞的微信车票设计,背后有哪些故事?
查看>>
Spring理论基础-面向切面编程
查看>>
BloomFilter 原理,实现及优化
查看>>
PHP本地文件包含漏洞环境搭建与利用
查看>>
OGNL设计及使用不当造成的远程代码执行漏洞
查看>>
Vue-cli + express 构建的SPA Blog(采用前后端分离方案)
查看>>
ios中的多播委托
查看>>
Java基础-单例模式
查看>>
轻仿QQ音乐之音频歌词播放、锁屏歌词
查看>>
MongoDB 4.0 RC 版本强势登陆
查看>>
AliOS Things网络适配框架 - SAL
查看>>
iOS 客户端与服务端做时间同步
查看>>
多个请求统一更新界面
查看>>
illuminate/routing 源码分析之注册路由
查看>>