上一页 1 2 3 4 5 6 ··· 11 下一页

2014年2月26日

欧几里德及其拓展和应用

摘要: 欧几里德定理求最大公约数:Datatype Gcd(Datatype a, Datatype b){ return (b == 0 ? a : Gcd (b, a%b));}运用的原理为辗转相除Gcd(a, b) == Gcd (b, a) == Gcd(-a, b) == Gcd(|a|, |b|)拓展欧几里得定理:求解方程ax + by = Gcd(a, b);int Gcd_value = 0, x = 0, y = 0; //Gcd_value为a,b的最大公约数int exGcd(int a, int b, int &Gcd_value, int &x, int .. 阅读全文

posted @ 2014-02-26 22:09 圣手摘星 阅读(174) 评论(0) 推荐(0) 编辑

2013年11月20日

博弈小部分资料收集

摘要: 首先提供一个大神的博客:http://blog.csdn.net/acm_cxlove/article/details/7854526以下是我从网上收集的关于组合博弈的资料汇总:有一种很有意思的游戏,就是有物体若干堆,可以是火柴棍或是围棋子等等均可。两个人轮流从堆中取物体若干,规定最后取光物体者取胜。这是我国民间很古老的一个游戏,别看这游戏极其简单,却蕴含着深刻的数学原理。下面我们来分析一下要如何才能够取胜。(一)巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。 显然,如果n=m+1,那么由于一次最多只能取m个,所. 阅读全文

posted @ 2013-11-20 20:03 圣手摘星 阅读(177) 评论(0) 推荐(0) 编辑

2013年11月18日

HDU 1079 Calendar Game

摘要: Calendar GameTime Limit: 5000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2165Accepted Submission(s): 1234Problem DescriptionAdam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they played the Calendar Game, in celebrati 阅读全文

posted @ 2013-11-18 14:47 圣手摘星 阅读(189) 评论(0) 推荐(0) 编辑

2013年11月15日

(转载) 随机数原理

摘要: 原文地址:http://www.cnblogs.com/pure/archive/2013/02/13/2909258.html如今大部分编译器的随机数算法还是线性同余算法,简称LCG。线性同余算法(LCG):http://en.wikipedia.org/wiki/Linear_congruential_generatorAlinear congruential generator(LCG) is analgorithmthat yields a sequence of randomized numbers calculated with alinear equation. The meth 阅读全文

posted @ 2013-11-15 16:46 圣手摘星 阅读(451) 评论(0) 推荐(0) 编辑

2013年11月14日

ZOJ 2588 Burning Bridges(求桥的数量,邻接表)

摘要: 题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2588Burning BridgesTime Limit:5 Seconds Memory Limit:32768 KBFerry Kingdom is a nice little country located on N islands that are connected by M bridges. All bridges are very beautiful and are loved by everyone in the kingdom. Of cour 阅读全文

posted @ 2013-11-14 21:27 圣手摘星 阅读(219) 评论(0) 推荐(0) 编辑

2013年11月12日

生成不重复的随机数对(C/C++)

摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int max_rand = 2001; 7 int a[max_rand], b[max_rand]; 8 struct node 9 {10 int x, y;11 bool operator < (const node q) const12 {13 if(x == q.x)14 return y < q.y;15 return x < q.x;16 ... 阅读全文

posted @ 2013-11-12 14:24 圣手摘星 阅读(731) 评论(0) 推荐(0) 编辑

2013年11月11日

比较两个文件是否相同(C/C++语言)

摘要: 1 #include 2 #include 3 const int max_r = 1024; 4 5 // Calculate the file size 6 void Get_file_size(char *name_1, char *name_2) 7 { 8 FILE *fp_1 = fopen(name_1, "r"); 9 FILE *fp_2 = fopen(name_2, "r"); 10 if (fp_1) 11 { 12 printf ("Size of %s : ", name_1); 13 ... 阅读全文

posted @ 2013-11-11 21:29 圣手摘星 阅读(4077) 评论(1) 推荐(0) 编辑

计算文件大小(C/C++语言)

摘要: 1 #include 2 3 int main() 4 { 5 FILE* fp; 6 if (fp = fopen("read files.exe", "r")) 7 { 8 fseek(fp, 0, SEEK_END);//SEEK_END :end of file 9 printf("%.1f KB\n", 1.*ftell(fp)/1024);10 fclose(fp);11 }12 return 0;13 } 阅读全文

posted @ 2013-11-11 21:21 圣手摘星 阅读(377) 评论(0) 推荐(0) 编辑

2013年11月6日

(转载)Nim游戏博弈(收集完全版)

摘要: 转载地址:http://www.cnblogs.com/exponent/articles/2141477.htmlNim游戏的概述:还记得这个游戏吗?给出n列珍珠,两人轮流取珍珠,每次在某一列中取至少1颗珍珠,但不能在两列中取。最后拿光珍珠的人输。后来,在一份资料上看到,这种游戏称为“拈(Nim)”。据说,它源自中国,经由被贩卖到美洲的奴工们外传。辛苦的工人们,在工作闲暇之余,用石头玩游戏以排遣寂寞。后来流传到高级人士,则用便士(Pennies),在酒吧柜台上玩。最有名的玩法,是把十二枚便士放成3、4、5三列,拿光铜板的人赢。后来,大家发现,先取的人只要在3那列里取走2枚,变成了1、4、5, 阅读全文

posted @ 2013-11-06 21:31 圣手摘星 阅读(186) 评论(0) 推荐(0) 编辑

2013年9月26日

将一串字符串全排列输出(回溯法)

摘要: 直接上代码 1 //Author :Freetion 2 //E-mail :Freetion@live.com 3 //file : 4 5 #include 6 #include 7 char str[1000], stack[1000];; 8 char ch[256]; 9 int count[256];10 int char_num, str_len;11 12 void deal_str()13 {14 int s[256];15 memset(s, 0, sizeof(s));16 memset(count, 0, ... 阅读全文

posted @ 2013-09-26 21:52 圣手摘星 阅读(508) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 11 下一页

导航