摘要: 偶然看见一段求根的神代码,于是就有了这篇博客; 对于求根问题,通常我们可以调用sqrt库函数,不过知其然需知其所以然,我们看一下求根的方法; 比较简单方法就是二分咯: 代码: 然而虽然其计算的结果和库函数一样,然而其效率较之库函数差数百倍,当然不是我说的神代码咯; 我们再看一下牛顿迭代法如何; 假设 阅读全文
posted @ 2016-09-18 18:58 geloutingyu 阅读(762) 评论(0) 推荐(0) 编辑
摘要: C. XOR and OR time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output C. XOR and OR time limit p 阅读全文
posted @ 2016-09-16 19:47 geloutingyu 阅读(297) 评论(0) 推荐(0) 编辑
摘要: B. Filya and Homework time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output B. Filya and Homewo 阅读全文
posted @ 2016-09-14 14:44 geloutingyu 阅读(206) 评论(0) 推荐(0) 编辑
摘要: C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is now 阅读全文
posted @ 2016-09-11 11:10 geloutingyu 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 76935 Accepted: 24323 Description Farmer John has been informed of the locat 阅读全文
posted @ 2016-09-09 22:05 geloutingyu 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 困难的串 题意: 如果一个字符串包含两个相邻的重复子串,则称它是“容易的串”,其他串称为“困难的串”。例如, BB、ABCDABCD都是容易的串,而D、DC、ABDAD、CBABCBA都是困难的串。 输入正整数n和L,输出由前L个字符组成的、字典序第k个困难的串。例如,当L=3时,前7个困难的串 分 阅读全文
posted @ 2016-09-08 11:13 geloutingyu 阅读(1350) 评论(1) 推荐(0) 编辑
摘要: 题目描述: 输入正整数n,把整数1,2...n组成一个环,使得相邻两个数和为素数。输出时从整数1开始逆时针排列并且不能重复; 例样输入: 6 例样输出: 1 4 3 2 5 6 1 6 5 2 3 4 方法1:(生成测试法,会超时) 方法2:(dfs+回溯) 代码: 阅读全文
posted @ 2016-09-07 19:42 geloutingyu 阅读(754) 评论(0) 推荐(0) 编辑
摘要: 重看了一下刘汝佳的白板书,上次写八皇后时并不是很懂,再写一次: 方法1:逐行放置皇后,然后递归; 代码: 方法2:思路和方法1差不多,区别是用二维数组vis[2][]来标记之前皇后的位置,判断是否会相互攻击 代码: 阅读全文
posted @ 2016-09-07 17:32 geloutingyu 阅读(831) 评论(0) 推荐(0) 编辑
摘要: B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but 阅读全文
posted @ 2016-09-07 09:48 geloutingyu 阅读(148) 评论(0) 推荐(0) 编辑
摘要: B. New Year and Old Property time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The year 20 阅读全文
posted @ 2016-09-06 12:53 geloutingyu 阅读(215) 评论(0) 推荐(0) 编辑