ID
Origin
Title
暑假集训-个人赛第四场 31 / 134 Problem A SPOJ AMR10A Playground
    Problem B SPOJ AMR10B Regex Edit Distance
  3 / 44 Problem C SPOJ AMR11C Robbing Gringotts
暑假集训-个人赛第四场 14 / 76 Problem D SPOJ AMR10D Soccer Teams
  3 / 14 Problem E SPOJ AMR10E Stocks Prediction
暑假集训-个人赛第四场 45 / 47 Problem F SPOJ AMR10F Cookies Piles
暑假集训-个人赛第四场 43 / 70 Problem G SPOJ AMR10G Christmas Play
暑假集训-个人赛第四场 8 / 10 Problem H SPOJ AMR10H Shopping Rush
暑假集训-个人赛第四场 26 / 104 Problem I SPOJ AMR10I Dividing Stones
  5 / 14 Problem J SPOJ AMR10J Mixing Chemicals

总结,读题太慢了,动归太弱了,脑袋太笨了。

A

  题意:给你个n边形,凸的,m次询问,每次两个点,问这两个点切开的两部分的较小的面积多大。

  area[i] 表示连接1 和 i 号顶点前面形成的面积有多大,询问 x 和 y 时, 其中一半的面积就是 side = |area[y] - area[x] - Area2(1, x, y) |, 答案就是 min(side, total - side)

B

  题意:给你两个正则表达式,求能够形成的表达式中相差最少的

  感觉超难

C  

  coming soon

D

  题意:给你1 - 9 每个数字出现的次数,0可以使用多次,求形成的最短的能够被11整除的数。

  比较好的动归题,明天再写详细的解释。

E

  coming soon

F,G

  签到题

H

  题意:顾客对商品 i 的 购买概率是 p[i], 每个顾客固定会买两件商品,可以相同,每次购买独立。 n件商品放在n层楼上,从 x 到 y 楼是所需的代价是 A*|x-y|^2 +B*|x-y| + C,问怎样安排商品的位置是的平均耗费的代价最小

  贪心,把购买概率晓得距离尽量远,概率大的距离尽量近,形成一个峰型的样子。排序后直接处理,然后根据处理好的得出答案。

  

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <fstream>
 4 #include <algorithm>
 5 #include <cmath>
 6 #include <deque>
 7 #include <vector>
 8 #include <queue>
 9 #include <string>
10 #include <cstring>
11 #include <map>
12 #include <stack>
13 #include <set>
14 #define LL long long
15 #define eps 1e-8
16 #define INF 0x3f3f3f3f
17 #define MU 10000
18 //#define OPEN_FILE
19 using namespace std;
20 int n, A, B, C;
21 int p[30], q[30];
22 int gcd(int a, int b){
23     if (a % b == 0){
24         return b;
25     }
26     return gcd(b, a % b);
27 }
28 int main()
29 {
30 #ifdef OPEN_FILE
31     freopen("in.txt", "r", stdin);
32     //freopen("out.txt", "w", stdout);
33 #endif // OPEN_FILE
34     int T;
35     scanf("%d", &T);
36     for (int cas = 1; cas <= T; cas++){
37         scanf("%d%d%d%d", &n, &A, &B, &C);
38         for (int i = 1; i <= n; i++){
39             scanf("%d",&p[i]);
40         }
41         int s = 1, t = n;
42         sort(p + 1, p + n + 1);
43         for (int i = 1; i <= n; i++){
44             if (i & 1){
45                 q[s++] = p[i];
46             }
47             else{
48                 q[t--] = p[i];
49             }
50         }
51         int ans = 0;
52         for (int i = 1; i <= n; i++){
53             for (int j = 1; j <= n; j++){
54                 int dis = abs(j - i);
55                 ans += q[i] * q[j] * (A * dis * dis + B * dis + C);
56             }
57         }
58         int u = gcd(ans, MU);
59         printf("%d/%d\n", ans / u, MU / u);
60         //printf("%d\n", ans);
61     }
62 }
View Code

相关文章: