- 博客(10)
- 收藏
- 关注
原创 86. Partition List(分割链表)--M
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the
2016-03-22 14:13:57 334
原创 LeetCode 172. Factorial Trailing Zeroes(阶乘结果尾数0的个数)---E
题目描述:Given an integer n, return the number of trailing zeroes in n!.Note : Your solution should be in logarithmic time complexity. 首先想到用组合数学的方法来算,n!中0的个数主要看的是1-n 各数的因数中2和5的次数,有多少对(2, 5),结果中就有多少个0,而
2016-03-22 08:42:18 336
原创 求二进制中1的个数
普通 (暴力) 方法:先求int位数,然后循环记录1的个数 int NumberOf1(int n) { int loopnum = 8 * sizeof(int), ans = 0; while(loopnum--){ ans += n&0x1; n = n>>1; }
2016-01-07 20:31:48 263
转载 C语言各类型限值
#include #include//#include #include #include #includeint main(void){system("cls");printf("char的位数:%u\n",CHAR_BIT);printf("char类型的最大值:%d\n",CHAR_MAX);printf("char类型的最小值:%d\n",CHAR_MIN);pr
2015-05-05 14:56:14 549
原创 POJ-1003 Hangover
说白了就是给一个数c,让你算1/2+1/3+1/4+1/5+……+1/n的结果能够刚好大于c的时候,n-1是多少,没啥好说的,直接放代码 需要注意的是,在判断两个浮点数是否“相等时”,要使用 if(fabs(a - b) 这样可以防止因为浮点类型的精度损失而造成的错误 。#include#include#define EPS 1e-8int main()
2014-10-06 14:38:29 359
原创 POJ-1002 487-3279 模拟问题
#include#includeint cmp(const void *a,const void *b){ char *c=(char *)a,*d=(char *)b; return strcmp(c,d);}void trans(char *a,char*b){int i,j;for(i=0,j=0;b[j]!=0&&i<7;++j)if(b[j]>='0'&&
2014-10-06 13:58:44 510
转载 很特别的一个动态规划入门教程
今天在网上看到一个讲动态规划的文章,是以01背包为例的,这文章和书上的讲解非常不一样,令我眼前一亮,于是转载一下下~~~(说明一下,本人非常痛恨教材公式定理漫天飞,实际的讲解却讲得非常枯涩难懂,这种中国式的教育已经延绵了几千年了,现在中国的教材还是这个样子,讲清楚些明白些就那么难么?高中有个老师讲的一句话一直觉得很有道理:“教得会天才不是真本事,能把博士生的东西讲到小学生都会用那才是真水平。”
2014-10-05 23:23:51 446
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人