# noip2016 愤怒的小鸟

## 题目描述

Kiana最近沉迷于一款神奇的游戏无法自拔。

## 输入输出样例

2
2 0
1.00 3.00
3.00 3.00
5 2
1.00 5.00
2.00 8.00
3.00 9.00
4.00 8.00
5.00 5.00

1
1

3
2 0
1.41 2.00
1.73 3.00
3 0
1.11 1.41
2.34 1.79
2.98 1.49
5 0
2.72 2.72
2.72 3.14
3.14 2.72
3.14 3.14
5.00 5.00

2
2
3


1
10 0
7.16 6.28
2.02 0.38
8.33 7.78
7.68 2.09
7.46 7.86
5.77 7.44
8.24 6.72
4.42 5.11
5.42 7.79
8.15 4.99

6


## 说明

【样例解释1】

【数据范围】

2.抛物线可能只能打到一头猪 3.抛物线上两个点横坐标不能相同.

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>

using namespace std;

int T, n, m,zhuangtai[20][20],dp[1 << 20];

struct node
{
double x, y;
}e[20];

bool jingdu(double a, double b)
{
return fabs(a - b) < 1e-6;
}

int main()
{
scanf("%d", &T);
while (T--)
{
memset(zhuangtai, 0, sizeof(zhuangtai));
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%lf%lf", &e[i].x, &e[i].y);
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
if (i != j)
{
if (jingdu(e[i].x, e[j].x))
continue;
double a = (e[j].y / e[j].x - e[i].y / e[i].x) / (e[j].x - e[i].x);
double b = e[i].y / e[i].x - a * e[i].x;
if (a >= 0.0)
continue;
for (int k = 1; k <= n; k++)
if (jingdu(a * e[k].x * e[k].x + b * e[k].x, e[k].y))
zhuangtai[i][j] |= (1 << (k - 1));
}
for (int i = 1; i < (1 << n); i++)
dp[i] = 2000000000;
dp[0] = 0;
for (int i = 0; i < (1 << n); i++)
for (int j = 1; j <= n; j++)
if (!(i & (1 << (j - 1))))
for (int k = j; k <= n; k++)
{
if (k == j)
dp[i | (1 << (j - 1))] = min(dp[i | (1 << (j - 1))], dp[i] + 1);
if (jingdu(e[j].x, e[k].x))
continue;
dp[i | zhuangtai[j][k]] = min(dp[i | zhuangtai[j][k]], dp[i] + 1);
}
printf("%d\n", dp[(1 << n) - 1]);
}

return 0;
}

posted @ 2017-07-26 23:32 zbtrs 阅读(...) 评论(...) 编辑 收藏