码迷,mamicode.com
首页 >  
搜索关键字:minimum sum lcm    ( 24851个结果
C语言优化实例:循环中减少判断
为了让编译器更好地优化循环,应该尽量让循环中减少判断,方法之一是将判断语句整合进表达式。还是这个例子: for (int i = 0; i < 1000*10; i++) { sum += data[i/1000][i%10]; } 假如我们需要加一个判断,只有非负整数才需要作求和运算: for (int i = 0; i {      if (data[i/10...
分类:编程语言   时间:2014-05-13 23:01:28    阅读次数:324
Codeforces 429D Tricky Function 最近点对
题目链接:点击打开链接 暴力出奇迹。 正解应该是最近点对,以i点为x轴,sum[i](前缀和)为y轴,求任意两点间的距离。 先来个科学的暴力代码: #include #include #include #include #include #include using namespace std; #define N 100050 #define ll __int64 ll a[N], su...
分类:其他好文   时间:2014-05-13 05:45:30    阅读次数:283
约束、视图、序列、伪列和索引
三目运算来计算总页数 totalpage=sum/pagesize+sum%pagesize==0?0:1;//计算总页数,sum为总记录数 2.第page页的记录的起始位置和结束位置分别为: pagesize*(page-1)+1;起始位置 pagesize*page;j、结束位置 注: 1.可以使用差集(minus)在数据库查询中实现分页,但效率低' 2.常用子查询将rownum作为另一结果集的字段来实现分页。 select ee.* from(select e.* , rownum rr...
分类:其他好文   时间:2014-05-13 05:14:41    阅读次数:303
leetcode第一刷_Minimum Path Sum
可以用递归简洁的写出,但是会超时。 dp嘛。这个问题需要从后往前算,最右下角的小规模是已知的,边界也很明显,是最后一行和最后一列,行走方向的限制决定了这些位置的走法是唯一的,可以先算出来。然后不断的往前推算。 用distance[i][j]保存从当前位置走到最右下角所需的最短距离,状态转移方程是从distance[i+1][j]和distance[i][j+1]中选一个小的,然后再加上自身的。...
分类:其他好文   时间:2014-05-13 00:13:56    阅读次数:339
[leetcode]Minimum Depth of Binary Tree @ Python
原题地址:http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/题意:Given a binary tree, find its minimum depth.The minimum depth is the number of no...
分类:编程语言   时间:2014-05-12 21:55:15    阅读次数:348
HDU 1394 Minimum Inversion Number (数据结构-线段树)
HDU 1394 Minimum Inversion Number (数据结构-线段树) 题目大意: 求逆序数。也就是给你一个序列,每次求逆序数,然再把第一个数放到这个序列的末尾,构成新的序列。问你这n个序列的最小的逆序数。 解题思路: 1、对于每个序列,其原来的逆序数记为 pre , 如果当前把该序列 第一个数 a[0] 移动到尾部,那么新序列的逆序数为 pre-a[i]+(n-a[i]-1) 因为序列中比a[i]大的数有 n-a[i]-1 个,比a[i]小的有 a[i]个。 因此只需求出...
分类:其他好文   时间:2014-05-12 07:07:01    阅读次数:301
[leetcode]Sum Root to Leaf Numbers @ Python
原题地址:http://oj.leetcode.com/problems/sum-root-to-leaf-numbers/题意:Given a binary tree containing digits from0-9only, each root-to-leaf path could repre...
分类:编程语言   时间:2014-05-12 01:28:30    阅读次数:440
leetcode --day12 Surrounded Regions & Sum Root to Leaf Numbers & Longest Consecutive Sequence
1、 ?? Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For e...
分类:其他好文   时间:2014-05-11 18:52:32    阅读次数:293
Hibernate查询方式---HQL方式
这一种我最常用,也是最喜欢用的,因为它写起来灵活直观,而且与所熟悉的SQL的语法差不太多。条件查询、分页查询、连接查询、嵌套查询,写起来与SQL语法基本一致,唯一不同的就是把表名换成了类或者对象。其它的,包括一些查询函数(count(),sum()等)、查询条件的设定等,全都跟SQL语法一样。###...
分类:系统相关   时间:2014-05-11 17:36:26    阅读次数:290
[LeetCode]Binary Tree Maximum Path Sum, 解题报告
题目 Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree,...
分类:其他好文   时间:2014-05-11 03:25:24    阅读次数:298
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!