- 博客(25)
- 收藏
- 关注
原创 poj 1011 Sticks
Thinking:1. Sort the sticks from the longest to the shortest.2. Among those small sticks, we start from the largest one Smax. The length of the complete stick L should range from Smax to (Sum of
2016-08-24 20:06:29 399
原创 UVA 12898 AND OR
Thinking: Having read the scale of number A and B, we know that we should use type long long int. And it is not realistic to use a loop to find the answer like what is described in the problem. What w
2016-08-21 14:18:56 492
原创 POJ 1753 Flip Game
Thinking: This one we used the enumeration method. Try the integer from 1 to 2^16 and use bits inside it to imitate different situations. We can have choices on each piece whether we flip it or not si
2016-07-23 18:17:50 277
原创 POJ 2828 Buy Tickets
Thinking: About this question, we have to think reversely. We first get all the input and arrange the sequence from the last guy who enters the queue. Because the last guy will not be effected by p
2016-07-16 15:22:27 318
原创 HDU 2795 Billboard
Thinking: There are 2 tips for this problem. (1) If we use struct , TLE may appear. Instead, I changed to use array maxl[] to store the largest space left in a row in this interval. (2) Since n <=
2016-07-12 12:22:23 267
原创 HDU 1394 Minimum Inversion Number
Thinking: Actually this problem can be solved in a violent way, which is not recommended. Here we made use of segment tree. The basic idea is to save the frequency(actually 0 or 1 for every number) of
2016-07-11 23:17:43 195
原创 UVA 478
Thinking: This is a simple computing geometry problem. But there are some points we need to pay attention to. Like: For triangles, the points that are input are not necessarily in a clockwise or anti-
2016-07-02 16:55:08 616
原创 UVA 211
Thinking:Use dfs to solve this problem. Try all the possibilities row by row.The lay out control is not so clear and you can use udebug to adjust them.AC code:#include#includeusing nam
2016-07-01 11:09:56 435
原创 UVA 623 [big numebr]
Thinking : In initialization, we will compute the factorial from 0! to 1000!. Or we will get TLE.ps: don't forget 0!AC code:#include#includeusing namespace std;int bit[1001][8];int fact
2016-06-22 23:47:32 275
原创 UVA 11736
Thinking: In this problem, the value can be as large as 2^64, so we should use unsigned long long to avoid wrong answer. Map is used to store the variable name and its value in string.AC code:
2016-06-16 11:22:20 331
原创 UVA 11688
Thinking:Find the shift of status. And observe the nature of rotation. Use father's status to solve both sons' status.AC code:#include#includeusing namespace std;int root;int L[100005];
2016-06-13 22:32:07 437
原创 UVA 11612
Thinking : We just need to compute the non-crossing closed path visiting all points. Remember to deal with the co-linear case.Pick the bottommost point a as the anchor point. For each point p, compu
2016-06-11 16:20:17 380
原创 UVA 11512
Thinking : Build a suffix array and corresponding height array. Find the largest height[i].AC code:#include#include#include#define maxn 1005int sa[maxn], height[maxn], n, w[maxn],
2016-06-10 00:11:03 871
原创 UVA 11500
Thinking: This problem involves the gambler's ruin theorem.wiki linkWe can consider EV1/D , EV2/D as coins in the original problem. And in the theorem, P1,P2 represent the probability that per
2016-06-06 20:42:21 356
原创 UVA 11198 (in easy way that i learnt from others)
Thinking: Use map to record the states. Use a integer created by certain rules to represent states. After solving talked above, just combine them with bfs.reference: https://github.com/morris821028/
2016-06-05 11:37:25 401
原创 UVA 11239
Thinking: Here we used the structure "map" to achieve our goal. Quite easy actually :)Remember to clear the map in next case.AC code:#include#include#include#include#include#include#incl
2016-06-04 15:01:51 316
原创 UVA 10930 [dp]
Thinking: First we get the sum. The meaning of array number[i][j] means: if we use numbers before sequence[i], what number can we get. If we can get the number , then number[i][j] = true. In the
2016-06-02 23:57:53 344
原创 UVA 10790
Thinking : It's a quite easy problem if you can find the relationship between P(a,b) and P(a-1,b) or P(a,b-1). Based on our math knowledge and observation from the picture, we can know that P(a,b)
2016-06-01 14:34:55 429
原创 UVA 10444
Thinking: This question is quite easy if you read it more carefully and actually the problem has already told you how to solve it.Tip : Since sometimes factorial(n) can be quite large, long long int
2016-06-01 11:28:18 679
原创 UVA 10514 【computing geometry】
Thinking: This problem is the combination of computing geometry and dijkstra algorithm. We consider bank1 and bank2 as two point. Consider each island as a point.There are some things that attent
2016-05-31 23:19:53 520
原创 UVA 10779 【maximum flow】
Thought :We consider Bob as source , then according to what bob has, we add_edge between Bob and stickers with weight number[sticker]. When it comes to his friends, since they will keep at least
2016-05-31 23:07:18 456
原创 UVA 10739 [classical dp]
Method : We use dp[i][j] (i If str[i] == str[j] , dp[i][j] = dp[i+1][j-1]. Or if str[i]!= str[j], dp[i][j] = min (dp[i+1][j],dp[i][j-1],dp[i+1][j-1]) + 1;dp[i+1][j] ----> delete operation,dp[i
2016-05-30 13:04:36 360
原创 UVA 10301
Well , this question is quite simple actually. Just use r1+r2 <d and fabs(r1-r2) < d to judge whether the two circle intersect with each other. Combine geometry and disjoint set together to get the so
2016-05-27 22:10:24 423
原创 UVA 10230
reference link:http://tmt514-blog.logdown.com/posts/549466-divide-and-conquer-method-v-l-shaped-brick-problemMethod: Here we used the divide and conquer method. Use recursion to deal with sub-block(
2016-05-27 14:11:44 499
原创 UVA 10140
meaning of the problem:Given two int L and U, find 2 pair of prime number. The first pair should be adjacent prime number the difference between whom is the smallest and that of the other pair sho
2016-05-27 14:07:44 400
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人