# include
# include
# include
using namespace std;
__int64 gcd(__int64 a,__int64 b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
int main()
{
int n,k,i,j,vis[810],m,num[810],x;
...
分类:
其他好文 时间:
2014-09-03 11:23:25
阅读次数:
192
//给出置换了s次后的序列,求原序列
# include
# include
# include
using namespace std;
int main()
{
int n,s,t,s1,i,cot;
int a[1010],b[1010],c[1010];
while(~scanf("%d%d",&n,&s))
{
for(i=1; i<...
分类:
其他好文 时间:
2014-09-02 21:29:15
阅读次数:
381
/*
对于每一个群,我们有两种换发:
1.群里换,拿群里最小的数t与其他每个数交换,共k-1次,花费为:sum+(k-2)*t.
2.将这个数列最小的数minn,拉入这个群,与该群最小的数t交换,然后用这个最小的数与其他数交换k-1次,然后再将minn与t换回来,这样
花费为:sum+t+(k+1)*minn
那么最小花费我们取两者中最小的,即sum+min{(k-2)*t,t+(k+1)*min...
分类:
其他好文 时间:
2014-09-02 15:59:54
阅读次数:
189
//问最少置换多少次变成有序序列
//每个位置都有个循环节 求全部位置循环节的最小公倍数
# include
# include
# include
using namespace std;
int gcd(int x,int y)
{
if(y==0)
return x;
return gcd(y,x%y);
}
int lcm(int x,int y)
{...
分类:
其他好文 时间:
2014-09-02 15:51:04
阅读次数:
223
知道了怎么置换之后,就可以用矩阵来置换了,但这道题一直关于置换的地方读不明白。#include #include #include using namespace std;const int Maxn=100;int pn[Maxn],xn[Maxn],bn[Maxn];int ansp[Maxn]...
分类:
其他好文 时间:
2014-09-02 11:55:34
阅读次数:
166
昨晚BestCoder第一题:一开始看了半天不知所云2333333其实它是让求置换群的轮换比如对于原题中的有o(1)=2, o(2)=5, o(3)=4, o(4)=3, o(5)=1其中o(1)=2,o(2)=5,o(5)=1就是一个轮换,转了一圈之后又回来了233同理,o(3)=4, o(4)=...
分类:
其他好文 时间:
2014-09-01 17:29:23
阅读次数:
262
Description
Shuffling the pixels in a bitmap image sometimes yields random looking images. However, by repeating the shuffling enough times, one finally recovers the original images. This should ...
分类:
其他好文 时间:
2014-09-01 15:39:53
阅读次数:
230
HDU 4985 Little Pony and Permutation
题目链接
题意:给定一个置换,输出分解成的循环
水题,直接模拟即可
代码:
#include
#include
#include
#include
using namespace std;
const int N = 100005;
int n, a[N], vis[N];
int...
分类:
其他好文 时间:
2014-09-01 15:39:03
阅读次数:
170
HDU 4986 Little Pony and Alohomora Part I
题目链接
题意:一些钥匙随机放在箱子里,现在问打开次数期望
思路:每种方式相当于一个置换的循环个数,那么考虑f[i]为i个箱子的情况,f[i + 1]要么就是放在最后多一个循环,要么就是插入中间循环个数不变,对应的转移为f[i + 1] = (f[i] + 1) / i + f[i] * (i -...
分类:
其他好文 时间:
2014-09-01 15:38:53
阅读次数:
196
Sorting is one of the most usedoperations in real life, where Computer Science comes into act. It iswell-known that the lower bound of swap based sorting is nlog(n).It means that the best possible sor...
分类:
其他好文 时间:
2014-09-01 10:50:23
阅读次数:
234