• ACM_Plants vs. Zombies(一元一次方程)


    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.
    

    Input:

    The input consists of several cases.The first line are two positive integer n,m,indicating the number of plants and zombies.Then the next n lines show the line (ax+by+c==0) of plants in the form of (a,b,c),Then the last lines show the positions of zombies in the form of (xi,yi).All input data is a 32-bit integer.

    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 }
  • 相关阅读:
    HDU-1102 Constructing Roads ( 最小生成树 )
    POJ-1287 Networking ( 最小生成树 )
    HDU-1272 小希的迷宫 ( 并查集 )
    Java基本数据类型、关键字
    观察者模式
    Android系统启动过程分析
    Activity启动过程源码分析(Android 8.0)
    Okhttp解析—Okhttp概览
    Okhttp解析—Interceptor详解
    Okhttp源码分析--基本使用流程分析
  • 原文地址:https://www.cnblogs.com/acgoto/p/9297631.html
Copyright © 2020-2023  润新知