摘要: 非常nice的一道行列式的题目。 考虑如果没有路径不相交这个限制的话,那么这个题就是一个行列式:设 a[i][j] 为从编号第i小的源点到编号第j小的汇点的路径条数,那么矩阵a[][]的行列式就是的答案,因为行列式的定义就是给行一个列的排列,贡献就是所有a[i][p[i]]再乘上 (-1)^(p[] 阅读全文
posted @ 2018-05-27 20:40 蒟蒻JHY 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 把lcm写成 (a+n)*(b+n) / gcd(a+n,b+n). 因为gcd可以辗转相减,所以就成了gcd(abs(a-b),a+n),一个常量一个变量之间的gcd,我们可以直接把abs(a-b)的所有约数找出来,然后看a要有某个约数的话n至少是多少,更新答案即可。(因为1e9以下的数的最多的约 阅读全文
posted @ 2018-05-27 19:50 蒟蒻JHY 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Discription Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level si, and no two cows having the same skill level. Ev 阅读全文
posted @ 2018-05-27 16:46 蒟蒻JHY 阅读(367) 评论(0) 推荐(0) 编辑
摘要: Problem Statement There is an integer sequence A of length N. Find the number of the pairs of integers l and r (1≤l≤r≤N) that satisfy the following co 阅读全文
posted @ 2018-05-27 11:04 蒟蒻JHY 阅读(331) 评论(0) 推荐(0) 编辑
摘要: Problem Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as 阅读全文
posted @ 2018-05-27 10:30 蒟蒻JHY 阅读(359) 评论(0) 推荐(0) 编辑