8月6日小練

2022-05-19 01:45:11 字數 2264 閱讀 2424

**:csust小練習1

以後每天21:30~23:30都有小練

a max sum

hdu 1003

大意是:給出n個數,找出最大的和,輸出起點和終點的編號

本來是暴力做,不出所料的超時了orz....

**:       15ms

1 #include2 #include3

using

namespace

std;

4int

main()523

if(sum<0) //

sum<0,拋棄前面的點

2428

}29 printf("

case %d:\n%d %d %d\n

",k,max,st,end);

30if

(t)31 printf("\n"

);32}33

return0;

34 }

b  to the max

poj 1050

這一題和a很像,a是一維的求最大和,b是二維的求最大和。      16ms

1 #include2 #include

3 #include4

using

namespace

std;

5int

main()632

}33}34 printf("

%d\n

",max);35}

36return0;

37 }

c     flying to the mars

hdu 1800         就是求下降子串行的最少個數,不過這道題可以先排序再求,因為不想再寫個函式,直接用sort,公升序排列,所以我這是求上公升子串行最少的個數。        296ms

1 #include2 #include

3 #include4 #include5

using

namespace

std;

6int

main()729

}30}31 printf("

%d\n

",number);32}

33return0;

34 }

d 改革春風吹滿地

hdu 2036   求多邊形的面積,給出的是n邊形的逆時針頂點座標。  

坑爹啊,這道題有公式!!!!!公式詳見:    

s = 0.5 * ( (x0*y1-x1*y0) + (x1*y2-x2*y1) + ... + (xn*y0-x0*yn) )

其中點(x0, y0), (x1, y1), ... , (xn, yn)為多邊形上按逆時針順序的頂點。                                   0ms

1 #include 2 #include 3 #include 4

using

namespace

std;

5int

main()

620 sum+=x1*b-y1*a; //

最後一組資料&第一組資料

21 printf("

%.1lf\n

",sum/2.0); //

取一半,保留一位小數22}

23return0;

24 }

f  滑雪

poj 1088   這道題是求最長的距離......我還以為是求高度差.....orz                         32ms

1 #include 2 #include 

3 #include 4

using

namespace

std;

5const

int maxn = 110;6

intmap[maxn][maxn],dp[maxn][maxn];

7int r,c,move[4][2]=;

8 inline int max(int x,inty)9

12int dfs(int x,int

y)13

24return

max;25}

26int

main()

2740 printf("

%d\n

",max+1

);41

return0;

42 }

8月22日小練

8月21日小練 a find the shortest common superstring hdu 1841 b 免費餡餅 hdu 1176 dp 思路 從時間後往前推,dp i j 表示在i,j地能接到的最多的餡餅數。46ms 1 include 2 include 3 include 4usi...

8月19日小練

csust訓練 a 小q系列故事 絲的逆襲 hdu 4500 一道以前就做過的題,而且當時也做出來了,就是找到乙個得分最高的位置,女為正數,男為負數,與鄰居性別不同則加上絕對值,否則相減。15ms 1 include2 include3 include 4using namespace std 5i...

8月15日小練

csust練習5 a n hdu 1042 n的階乘,大數相乘,這裡的n 10000,故可以用陣列不用字串。1546ms 1 include 2 include 3 using namespace std 4int a 40000 5 intmain 615 a 0 1 0 記錄陣列的長度 16 a...