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…
题目描述 Like all bovines, Farmer John's cows speak the peculiar 'Cow'language. Like so many languages, each word in this language comprisesa sequence of upper and lowercase letters (A-Z and a-z).  A wordis valid if and only if each ordered pair of adjac…
n<=250个大写字母和m<=250个小写字母,给p<=200个合法相邻字母,求用这些合法相邻字母的规则和n+m个字母能合成多少合法串,答案mod 97654321. 什么鬼膜数.. f(i,j,k)--i个大写字母,j个小写字母,最后一个字母是k,,其中k是小写字母,p是能接在k前面的任意字母,k是大写字母的话同理. 这样复杂度是n*m*26*26?假的!i,j确定后只有p种合法转移,所以就n*m*p. trick:记得算i=0和j=0的情况!!! #include<cstrin…
康托展开 裸的康托展开&逆康托展开 康托展开就是一种特殊的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…
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…
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…
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…
[USACO2002 Feb]奶牛自行车队 Time Limit: 1000 ms Memory Limit: 131072 KBytes Description N 头奶牛组队参加自行车赛.车队在比赛时排成一列,需要绕场S 圈.由于空气阻力的作用,领队奶牛消耗的体力要比后面的多.每头奶牛的初始体力都是相同的,记作M,体力减为负数的奶牛只能中途退赛,体力也不会在比赛途中恢复,但最后只要有一位队员到达终点就算完成了比赛. 比赛最小的单位时间是分钟.车队在每分钟必须绕赛场整数圈,最少是每分钟一圈.如…
Description Recently, the cows have been competing with strings of balanced  parentheses and comparing them with each other to see who has the  best one.  Such strings are scored as follows (all strings are balanced): the  string "()" has score…