[USACO2011 Feb] Cow Line】的更多相关文章

3301: [USACO2011 Feb] Cow Line Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 67  Solved: 39[Submit][Status] Description The N (1 <= N <= 20) cows conveniently numbered 1...N are playing yet another one of their crazy games with Farmer John. The co…
3301: [USACO2011 Feb] Cow Line Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 82  Solved: 49[Submit][Status][Discuss] Description The N (1 <= N <= 20) cows conveniently numbered 1...N are playing yet another one of their crazy games with Farmer Joh…
http://www.lydsy.com/JudgeOnline/problem.php?id=3301 其实这一题很早就a过了,但是那时候看题解写完也是似懂非懂的.... 听zyf神犇说是康托展开,然后拖到今天才来看看... sad.. 从不知道那里来的文档里边抄的: 康托展开就是一种特殊的哈希函数,它的使用范围是对于n个数的排列进行状态的压缩和存储.X=a[n]*(n-1)!+a[n-1]*(n-2)!+…+a[i]*(i-1)!+…+a[2]*1!+a[1]*0! 其中,a为整数,并且0<…
康拓展开/逆展开 模板 #include<algorithm> #include<iostream> #include<cstdio> #define int long long using namespace std; inline int rd(){ int ret=0,f=1;char c; while(c=getchar(),!isdigit(c))f=c=='-'?-1:1; while(isdigit(c))ret=ret*10+c-'0',c=getcha…
原题链接https://www.lydsy.com/JudgeOnline/problem.php?id=3301 康拓展开和逆展开的模板题. #include<iostream> #include<cstring> #include<cstdio> #define maxn 21 using namespace std; inline int read(){ register int x(0),f(1); register char c(getchar()); whi…
康托展开 裸的康托展开&逆康托展开 康托展开就是一种特殊的hash,且是可逆的…… 康托展开计算的是有多少种排列的字典序比这个小,所以编号应该+1:逆运算同理(-1). 序列->序号:(康托展开) 对于每个数a[i],数比它小的数有多少个在它之前没出现,记为b[i],$ans=1+\sum b[i]* (n-i)!$ 序号->序列:(逆康托展开) 求第x个排列所对应的序列,先将x-1,然后对于a[i],$\left\lfloor \frac{x}{(n-i)!} \right\rflo…
2274: [Usaco2011 Feb]Generic Cow Protests Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 196  Solved: 122[Submit][Status] Description Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cows are conducting another…
2272: [Usaco2011 Feb]Cowlphabet 奶牛文字 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 138  Solved: 97[Submit][Status][Discuss] Description Like all bovines, Farmer John's cows speak the peculiar 'Cow'language. Like so many languages, each word in this…
3300: [USACO2011 Feb]Best Parenthesis Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 89  Solved: 42[Submit][Status] Description Recently, the cows have been competing with strings of balanced parentheses and comparing them with each other to see who…
[BZOJ3939][Usaco2015 Feb]Cow Hopscotch Description Just like humans enjoy playing the game of Hopscotch, Farmer John's cows have invented a variant of the game for themselves to play. Being played by clumsy animals weighing nearly a ton, Cow Hopscotc…