码迷,mamicode.com
首页 >  
搜索关键字:php array 数组    ( 182180个结果)
Codeforces Round #246 (Div. 2)
题目链接:Codeforces Round #246 (Div. 2) A:直接找满足的人数,然后整除3就是答案 B:开一个vis数组记录每个衣服的主场和客场出现次数,然后输出的时候主场数量加上重复的,客场数量减掉重复的 C:原来是YY乱搞的,原来是哥德巴赫猜想,一个合数可以表示为3个质数相加,然后就先打个素数表,然后从最小的数字一个个模拟往前放即可,放的时候走的步数直接拆成都是质数即可 ...
分类:其他好文   时间:2014-05-18 18:39:37    阅读次数:298
hdu 2066 一个人的旅行(裸dijkstra)
http://acm.hdu.edu.cn/showproblem.php?pid=2066 求多源多汇的最短路,n最大为1000,floyd三重循环会超时。继续dijkstra吧。 #include #include #include #include #include #include #include #include #define LL long long #...
分类:其他好文   时间:2014-05-18 18:26:39    阅读次数:238
leetcode: 3Sum
题目:给定一个数组和一个目标值,返回所有不重复的3元组,每个元组的和等于目标值,且元组中,各元素按飞递减顺序。 先对其进行排序,在利用2sum,在2sum中,要求和为0,这里可以将数组中的元素的相反数作为和,找到另外两个数,那么三者的和为0。 在2sum中,经过排序后,总的时间复杂度是排序算法的复杂度占主导O(NlogN),在查找时是遍历数组,复杂度为O(n)。那么在3sum中,首先进行排序,...
分类:其他好文   时间:2014-05-18 14:02:28    阅读次数:249
LeetCode 016 3Sum Closest
【题目】 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {...
分类:其他好文   时间:2014-05-18 10:37:57    阅读次数:269
LeetCode 017 4Sum
【题目】 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: Elements in a quadruplet (a,b,c,d) must be in non-descending ord...
分类:其他好文   时间:2014-05-18 08:46:04    阅读次数:227
[leetcode]:Two Sum
题目:给定一个数组,以及一个 target 值,target 表示目标和,要求在数组中找到两个数,xi,xj,使得 xi + xj = target。返回值是找到的两个数的下标索引,升序排序。假定至少存在一对解。 分析:对于要处理数组的问题,我们的理想状态都是给定的数组是有序的就好了,在有序后,我们就可以首位各放一个标记。类似于二分查找。 vector twoSum(vector &n...
分类:其他好文   时间:2014-05-18 08:04:03    阅读次数:234
Dijkstra
昨天上课的时候老师讲了Dijkstra的OpenMP版本,为了给我们演示OpenMP的一些指令等,拿Dijkstra算法做了范例,自己想写写,可OpenMP的版本昨天还是没理解,没能写出来,贴一下自己未写完的代码,做个记录,等有时间了研究一下哈! #include #include //定义节点的个数 #define NUM_VERTEX 5 //定义标记数组 bool visited[N...
分类:其他好文   时间:2014-05-18 07:52:46    阅读次数:248
php删除数组中指定值的元素
php删除数组中指定值的元素...
分类:Web程序   时间:2014-05-18 07:15:44    阅读次数:235
[LeetCode]3Sum Closest
3SumClosest Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution....
分类:其他好文   时间:2014-05-18 05:57:48    阅读次数:244
LeetCode 015 3Sum
【题目】 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c) The so...
分类:其他好文   时间:2014-05-18 03:15:50    阅读次数:287
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!