• 飞向另一个世界


    Yet another end of the world

    Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
    Total Submission(s): 0    Accepted Submission(s): 0


    Problem Description
    In the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any more and the Rapture finally comes in. Fortunately people have already found out habitable planets, and made enough airships to convey all the human beings in the world. A large amount of airships are flying away the earth. People all bear to watch as this planet on which they have lived for millions of years. Nonetheless, scientists are worrying about anther problem…
    As we know that long distance space travels are realized through the wormholes, which are given birth by the distortion of the energy fields in space. Airships will be driven into the wormholes to reach the other side of the universe by the suction devices placed in advance. Each wormhole has its configured attract parameters, X, Y or Z. When the value of ID%X is in [Y,Z], this spaceship will be sucked into the wormhole by the huge attraction. However, the spaceship would be tear into piece if its ID meets the attract parameters of two wormholes or more at the same time.
    All the parameters are carefully adjusted initially, but some conservative, who treat the Rapture as a grain of truth and who are reluctant to abandon the treasure, combine with some evil scientists and disrupt the parameters. As a consequence, before the spaceships fly into gravity range, we should know whether the great tragedy would happen or not. Now the mission is on you.
     
    Input
    Multiple test cases, ends with EOF.
    In each case, the first line contains an integer N(N<=1000), which means the number of the wormholes.
    Then comes N lines, each line contains three integers X,Y,Z(0<=Y<=Z<X<2*109).
     
    Output
    If there exists danger, output “Cannot Take off”, else output “Can Take off”.
     
    Sample Input
    2 7 2 3 7 5 6 2 7 2 2 9 2 2
     
    Sample Output
    Can Take off Cannot Take off
    #include <stdio.h>
    #include <stdlib.h>
    #define M 1001
    struct prem
    {
        int x;
        int y;
        int z;
    };
    struct prem tray[M];
    
    int cmp(const void *a, const void *b)
    {
        struct prem *m = (struct prem *)a;
        struct prem *n = (struct prem *)b;    
        if(m->y != n->y)
            return m->y - n->y;
        return m->z - n->z;
    }
    
    int main()
    {
        int n, flag, i, j;
        while(scanf("%d", &n) != EOF){
    
            for(i = 1; i <= n; i++){
    
                    scanf("%d %d %d", &tray[i].x, &tray[i].y, &tray[i].z);
    
            }
            qsort(tray + 1, n, sizeof(tray[0]), cmp);
            flag = 0;
            for(i = 1; i < n; i++)
            {
                if(tray[i].y == tray[i+1].y || tray[i].z >= tray[i+1].y )//判断交集条件
                {
                    flag = 1;
                    break;
                }
            }
            if(flag == 1)
                printf("Cannot Take off
    ");
            else
                printf("Can Take off
    ");
            
        }
        return 0;
    }
    View Code

    我的思路是 两个虫洞的范围有交集就有危险, 所以只需判断y和z大小即可。不知为什么,挖了

  • 相关阅读:
    正则表达式的使用
    代理IP
    搜索Python编程获取相关图书信息
    使用post请求登陆
    使用.NetCore自带的后台作业,出入队简单模拟生产者消费者处理请求响应的数据
    windows下的cmd和powershell修改字体为YaHei Consolas Hybrid
    粤剧名家专辑精选大全集(193CD)
    Power Query常用操作
    Excel 常用函数
    VbenadminApiSelect Invalid prop: type check failed for prop "onUpdate:value". Expected Function, got Array
  • 原文地址:https://www.cnblogs.com/the-one/p/3264833.html
Copyright © 2020-2023  润新知