2013年10月22日
摘要: 转载了一篇关于全排列的哈希函数,Poj1077就是应用了全排列的哈希;我们经常使用的数的进制为“常数进制”,即始终逢p进1。例如,p进制数K可表示为K = a0*p^0 + a1*p^1 + a2*p^2 + ... + an*p^n (其中0 pi,那么,如果在排列Q中qi之前的元素x与qi构成逆序对,即有x > qi,则在排列P中pi之前也有相同元素x > pi(因为x > qi且qi > pi),即在排列P中pi之前的元素x也与pi构成逆序对,所以pi的逆序数大于等于qi的逆序数。又qi与pi在排列P中构成pi的逆序对,所以pi的逆序数大于qi的逆序数。(2)同理 阅读全文
posted @ 2013-10-22 20:38 straw_berry 阅读(689) 评论(0) 推荐(0) 编辑
摘要: Time Limit:1000MSMemory Limit:65536KTotal Submissions:22207Accepted:9846Special JudgeDescriptionThe 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all pa 阅读全文
posted @ 2013-10-22 20:36 straw_berry 阅读(507) 评论(0) 推荐(0) 编辑