最大公约数:代码: 1 #include 2 #include 3 long long gcd(int x,int y ) 4 { 5 return (y==0)?x:gcd(y,x%y); 6 } 7 8 int main() 9 {10 int m,n;11 whi... Read More
posted @ 2014-07-24 17:40 kinghold Views(166) Comments(0) Diggs(0) Edit
题目地址: Eps题目大意; a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 求有多少个解,范围是[-50,50].注意(x!=0)。解题思路: O(n^5)超时。 可以转换方程式 a1x13+ a2x23=-(a3x33+ a4x43+ a5x53) 时间复杂度降低到... Read More
posted @ 2014-07-24 16:57 kinghold Views(177) Comments(0) Diggs(0) Edit
题目地址:Check the difficulty of problems题目大意: 在编程比赛中有M个题,T支队伍。要求冠军团队至少做出N道题。 求每对至少做出一道题的同时冠军队至少做出N道题的概率。解题思路: 概率+DP。首先做的是将题目求的概率转化成:每队均至少做一题的概率P1 减去 每... Read More
posted @ 2014-07-24 11:40 kinghold Views(139) Comments(0) Diggs(0) Edit
这是一个很有用的HASH 的函数,对长短字符串都很有用。 代码: 1 // ELF Hash Function 2 unsigned int ELFHash(char *str) 3 { 4 unsigned int hash = 0; 5 unsigned int x =... Read More
posted @ 2014-07-24 08:36 kinghold Views(261) Comments(0) Diggs(0) Edit