Leetcode_num15_Maximun Subarray,leetcode題目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1]
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 【部分題解】,2014牡丹江亞洲地區賽邀請賽K題:想法題分析:兩種變化,添加和交換,首先:星號是n的話最少需要的數字是n+1,那麼可以首先判斷數字夠不夠,不夠的話現在最前面添數字,如果滿足的話直接類比如果數字不夠的話把當前的星號和最後一個數字交換即可。css函數可以不用。AC代碼:#include <cstdio>#include
hdu 4027 Can you answer these queries?(線段樹),hdu4027題目大意:hdu 4027 Can you answer these queries?題目大意:給定一個長度為N的序列,Q次操作,0 l r:將區間l r之間的數開根;1 l r:查詢l r之間數的和。解題思路:這題看上去是一道線段樹,其實它就是一道線段樹,只不過不用想的太複雜,因為開根的趨近1的速度非常快,所以每個節點只要標記區間內元素是否相同即可。複雜度妥妥的。#include
poj 2482 Stars in Your Window(掃描線),poj2482題目連結:poj 2482 Stars in Your Window題目大意:平面上有N個星星,問一個W∗H的矩形最多能括進多少個星星。解題思路:掃描線的變形。只要以每個點為左上方,建立矩形,這個矩形即為框框左下角放的位置可以括到該點,那麼N個星星就有N個矩形,掃描線處理哪些位置覆蓋次數最多。#include <cstdio>#include <cstring>#include
poj2155 Matrix 二維數組數組,poj2155matrixhttp://poj.org/problem?id=2155MatrixTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 18769 Accepted: 7078DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[