摘要:
n participants of «crazy tea party» sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes... 阅读全文
posted @ 2015-08-27 20:31
hxy_has_been_used
阅读(137)
评论(0)
推荐(0)
摘要:
倒着考虑,如果最后一只牛的前面有x只比它小,那么它就是第x+1只牛,从序列中去掉它。对倒数第二只牛来说也同理。可以用树状数组来维护前缀和,一开始每个位置都是1,求出结果的牛从树状数组中删掉(update成0),即可获得答案。 1 #include 2 #include 3 #include 4... 阅读全文
posted @ 2015-08-27 20:00
hxy_has_been_used
阅读(113)
评论(0)
推荐(0)
摘要:
很容易想到插板法的模型,即:n个没有区别的小球放到m个不同的盒子里(允许某些盒子为空)的方法数c[n + m - 1][m - 1]。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int MOD = 10... 阅读全文
posted @ 2015-08-27 10:21
hxy_has_been_used
阅读(118)
评论(0)
推荐(0)
摘要:
想到分解质因数的话就很简单了,注意此题要求幂次至少为1,所以幂次为0即为Impossible to divide。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 10... 阅读全文
posted @ 2015-08-27 10:06
hxy_has_been_used
阅读(232)
评论(0)
推荐(0)