上一页 1 ··· 50 51 52 53 54 55 56 57 58 ··· 62 下一页
摘要: 思路:模板。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int dp[100005]; 8 int coms[505]; 9 int value[505];10 int max(int a,... 阅读全文
posted @ 2015-04-17 23:30 xcw0754 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 思路:暴力搜,用BFS的方式,生成每一种可能,再对每一种可能进行判断是否回文,进行统计。严重超时!计算一个25个字符的,大概要20多秒! 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std... 阅读全文
posted @ 2015-04-17 21:06 xcw0754 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 运算符优先级参考站点 点我直达 字符串与数字的互转: (1)atof 字符串→双精度浮点型 double atof (const char* str); (2)atoi 字符串→整型 int atoi (const char * str); (3)atol 字符串→整型 注意:long、int、lo 阅读全文
posted @ 2015-04-17 11:03 xcw0754 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 题意:一个码如果是另一个码的前缀,则is not immediately decodable,不可直接解码,也就是给一串二进制数字给你,你不能对其解码,因解码出来可能有多种情况。思路:将每个码按长度从短到长排序,逐个与其后面的码比较,若前面相同位数完全一样了,那就可以输出了。 1 #include ... 阅读全文
posted @ 2015-04-16 23:04 xcw0754 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 如题思路:暴力就行了。1ms的暴力!!!别的牛人写出来的,我学而抄之~ 1 int strStr(char* haystack, char* needle) { 2 if (!haystack || !needle) return -1; 3 for (int i =... 阅读全文
posted @ 2015-04-14 22:53 xcw0754 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题意:我们有一个2xN的长条形棋盘,然后用1x2的骨牌去覆盖整个棋盘。对于这个棋盘,一共有多少种不同的覆盖方法呢?思路:这是斐波那契数列啊,f[n] = f[n-1] + f[n-2],初始时f[0]=1,f[1]=1,f[2]=2。其实跟下面的递推思路差不多吧。但是关于这种简单,一般都可以用矩阵快... 阅读全文
posted @ 2015-04-13 23:53 xcw0754 阅读(404) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2015-04-11 20:31 xcw0754 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 题意:天啊!我竟然看不懂题意,还去翻别人的代码才懂!给定一个字符串,求该字符串二十六进制的总值。思路:'A'~'Z'就是1到26,"AA"=26+1=27,"BA"=26*2+1=53,"CBA"=26*26*3+26*2+1。相当于321(十进制),那么就是10*10*3+10*2+1,说第3条式... 阅读全文
posted @ 2015-04-10 23:53 xcw0754 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一个数组,将该数组的后k位移动到前n-k位之前。(本题在编程珠玑中第二章有讲)思路:方法一:将后K位用vector容器装起来,再移动前n-k位到后面,再将容器内k位插到前面。 1 class Solution { 2 public: 3 void rotate(int nums[]... 阅读全文
posted @ 2015-04-10 21:58 xcw0754 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回。思路:循环32轮,将n往右挤出一位就补到ans的尾巴上。 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 if( !n... 阅读全文
posted @ 2015-04-09 23:31 xcw0754 阅读(114) 评论(0) 推荐(0) 编辑
上一页 1 ··· 50 51 52 53 54 55 56 57 58 ··· 62 下一页