Plants vs. Zombies
Time Limit: 2000/1000ms (Java/Others)
Problem Description:
There is a zombie on your lawn,There is a zombie on your lawn,There are many zombies on your lawn,So can you defeat them?You have many plants that can kill the zombie in a hit and your plants can kill all zombies on their straight shooting path.
Output:
Print "duang" if you can kill all zombies,else print "eat your brain".
Sample Input:
2 2
1 1 1
1 2 3
1 -2 -1 0
Sample Output:
duang
解题思路:简单判断m个坐标是否都满足n个方程ax+by+c==0中的任意一个,如果都满足,则输出"duang",否则输出"eat your brain",水过!
AC代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3 const int maxn = 1e6+5;//开大一点
4 int n,m,num,x,y,a[maxn],b[maxn],c[maxn];
5 int main(){
6 while(~scanf("%d%d",&n,&m)){
7 for(int i=0;i<n;++i)scanf("%d%d%d",&a[i],&b[i],&c[i]);
8 num=0;
9 for(int j=0;j<m;++j){
10 scanf("%d%d",&x,&y);
11 for(int i=0;i<n;++i)
12 if(a[i]*x+b[i]*y+c[i]==0){num++;break;}
13 }
14 if(num!=m)printf("eat your brain
");
15 else printf("duang
");
16 }
17 return 0;
18 }