uva 11077 置换
/**
给定一个置换,看能不能存在一个置换A^2 = B
思路; 循环节长度为偶数n的置换只能由循环节长度为长度2*n 的置换A*A 而变得。所以只需求出循环节,看循环节长度为偶数的个数是否为偶数个即可。。
训练指南
**/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = ; unsigned long long f[maxn][maxn];
int main()
{
memset(f,,sizeof(f));
f[][] = ;
for(int i=;i<=;i++){
for(int j=;j<i;j++){
f[i][j] = f[i-][j];
if(j>) f[i][j] += f[i-][j-]*(i-);
}
}
int n,k;
while(cin>>n>>k){
if(n==&&k==)
break;
cout<<f[n][k]<<endl;
}
return ;
}
uva 11077 置换的更多相关文章
- LA 3641 Leonardo的笔记本 & UVA 11077 排列统计
LA 3641 Leonardo的笔记本 题目 给出26个大写字母的置换B,问是否存在要给置换A,使得 \(A^2 = B\) 分析 将A分解为几个循环,可以观察经过乘积运算得到\(A^2\)后,循环 ...
- UVA 11077 - Find the Permutations(递推)
UVA 11077 - Find the Permutations option=com_onlinejudge&Itemid=8&page=show_problem&cate ...
- UVa 11077 Find the Permutations(置换+递推)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35431 [思路] 置换+递推 将一个排列看作一个置换,分解为k个循 ...
- 【UVA 11077】 Find the Permutations (置换+第一类斯特林数)
Find the Permutations Sorting is one of the most used operations in real life, where Computer Scienc ...
- UVA - 11077 Find the Permutations (置换)
Sorting is one of the most usedoperations in real life, where Computer Science comes into act. It is ...
- UVA 11077 Find the Permutations 递推置换
Find the Permutations Sorting is one of the most used operations in real ...
- Uva 11077 Find the Permutations [置换群 DP]
题意: 给定$n$和$k$,问有多少排列交换$k$次能变成升序 $n \le 21$ $uva$貌似挂掉了$vjudge$上一直排队 从某个排列到$1,2,...,n$和从$1,2,...,n$到某个 ...
- UVa 11330 (置换 循环的分解) Andy's Shoes
和UVa11077的分析很类似. 我们固定左脚的鞋子不动,然后将右脚的鞋子看做一个置换分解. 对于一个长度为l的循环节,要交换到正确位置至少要交换l-1次. #include <cstdio&g ...
- UVa 11077 (循环分解 递推) Find the Permutations
把{1, 2, 3,,, n}叫做自然排列 本题便是求有多少个n元排列P要至少经过k次交换才能变为自然排列. 首先将排列P看做置换,然后将其分解循环,对于每个长度为i的循环至少要交换i-1次才能归位. ...
随机推荐
- LINQ to SQL的CRUD操作
创建数据对象模型 sqlmetal /code:"C:\MyProjects\VS2008\Data\LinqConsoleApp2\LinqConsoleApp2\northwnd.cs& ...
- Ubuntu 用 pptp 建立 vpn 服务
1.下载pptp sudo apt-get install pptpd 2.配置pptp 须要改动配置下面的文件: pptpd.conf文件:配置链接后的主机ip和能够分配的内存范围 vi /etc/ ...
- 汉诺塔 python版
汉诺塔问题:如果将n个盘子(由小到大)从a通过b,搬到c,搬运过程中不能出现小盘子在大盘子下面的情况. 思路分析:假设前要移动第100个盘子,分两步走,移动第99个:再移动第100个:而要移动第99个 ...
- css代码优化篇
心情比较不咋地,不想说什么了 代码演示如下: 不推荐 .fw-800 { font-weight: 800; } .red { color: red; } 推荐 .heavy { font-weigh ...
- MVC过滤器进行统一登录验证
统一登录验证: 1.定义实体类Person:利用特性标签验证输入合法性设计登录页面 1 2 3 4 5 6 7 8 9 public class Person { [DisplayName(& ...
- ios开发学习笔记(1)
objective-c基础总结 第一二章 1.application:didiFinishLauchingWithOptions:程序启动后立即执行 2.启动界面代码格式:self.window = ...
- c#软件工程师笔试题
近来有打算重新找工作,还没提离职,投了几家公司简历,其中一家比较中意的公司给发了面试题,其实,好像是好几天前的事了,主要是Gmail邮箱很少用,所以一直都没去看,今天看到题目给解了. 题目如下: 题目 ...
- POJ 1797 Heavy Transportation 最短路变形(dijkstra算法)
题目:click here 题意: 有n个城市,m条道路,在每条道路上有一个承载量,现在要求从1到n城市最大承载量,而最大承载量就是从城市1到城市n所有通路上的最大承载量.分析: 其实这个求最大边可以 ...
- BZOJ 1221: [HNOI2001] 软件开发(最小费用最大流)
不知道为什么这么慢.... 费用流,拆点.... --------------------------------------------------------------------------- ...
- 自定义jquery手风琴插件
手风琴效果是项目中使用频率较高的一种效果,原来项目一直都在用easyui的,临近年末,试着自己写了一个 css样式 /* CSS Document */ body { margin: 0 auto; ...