zoukankan      html  css  js  c++  java
  • hnust Snowman

    问题 D: Snowman

    时间限制: 1 Sec  内存限制: 128 MB
    提交: 203  解决: 94
    [提交][状态][讨论版]

    题目描述

    前言:这是某比赛的热身题,本题主要考察英文水平,只要看懂题意,AC本题会很快!
        Welcome to Da Dong Bei kingdom in this winter!
     
        Tang and Jiang are good friends. They are trying to building some snowmen. To build a snowman, i.e., an anthropomorphic snow sculpture, Tang and Jiang have to roll some snowballs respectively. It is known that snow becomes suitable for packing when approaching the melting point, which allows for the construction of a large snowball by simply rolling it, until it grows to the desirable size. However, they don’t know if the snowman is stable with the size they make.
     
        In specific, snowmen are usually built by two spheres, one from Tang, and another from Jiang. Assuming the radius of the upside snowball be R1 and the radius of the downside snowball be R2, a snowman is stably built if 3/2*R1<=R2<=2*R1(R1,R2,are positive).
     
        Tang and Jiang want to know whether there is a feasible case for them to build a steady snowman.

    输入

        There are multiple test cases.
        For each test case, the first line contains two integers N(1<=N<=10) and M(1<=M<=10) indicating the number of snowballs Tang and Jiang rolled respectively; the next two lines have respectively N intergers and M integers separated by spaces, denoting the radius of snowballs they rolled.
        You can assume all the integers are not larger than 10000.

    输出

    For each case, print “Yes” in a single line if there is at least one feasible solution; Print “No” otherwise.

    样例输入

    2 1
    5 10
    7
    2 1
    5 10
    6
    

    样例输出

    No
    Yes


    简单数学

    #include <cstdio>
    int absa(int a)
    {
        return a>0?a:-a;
    }
    int main()
    {
        int n,m,i,j,flag;
        int s[11],c[11];
        while(scanf("%d%d",&n,&m)!=EOF)
        {
            flag=0;
            for(i=0;i<n;i++) scanf("%d",&s[i]);
            for(i=0;i<m;i++) scanf("%d",&c[i]);
            for(i=0;i<n;i++)
            for(j=0;j<m;j++)
            {
                if(absa(s[i]-c[j])>(s[i]+1)/2)
                {
                    printf("Yes
    ");
                    flag=1;
                    break;
                }
            }
            for(i=0;i<m;i++)
            for(j=0;j<n;j++)
            {
                if(absa(c[i]-s[j])>(c[i]+1)/2)
                {
                    printf("Yes
    ");
                    flag=1;
                    break;
                }
            }
            if(!flag)
                printf("No
    ");
        }
        return 0;
    }
    View Code
     
  • 相关阅读:
    教准备租房的同学如何避开坑!
    mvc3中controler和view之间的数据传递
    WebMail发送邮件
    mvc Razor视图语法与Aspx视图语法对比
    SQL Server sql分页查询
    WCF之一
    C++总结笔记(一)抽象、多态、继承
    Perl脚本学习经验(二)常用命令举例
    makefile学习经验(四)编译生成动态库文件(方式二)
    makefile学习经验(三)编译生成动态库文件(方式一)
  • 原文地址:https://www.cnblogs.com/wandso/p/10062056.html
Copyright © 2011-2022 走看看