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
     
  • 相关阅读:
    input,textarea限制字数,实时绑定
    rem布局和vw布局的理解
    HTML5+CSS3响应式垂直时间轴,高端,大气
    谈谈前端工程化是个啥?
    js动态添加html标签和属性_手动插入meta、script、div、img等标签
    textarea换行_在textarea中如何换行的实现总汇
    css常用的颜色单位表示法
    CSS3 2D转换
    为什么设置overflow为hidden可以清除浮动带来的影响
    什么是数据交互格式?xml和json优缺点
  • 原文地址:https://www.cnblogs.com/wandso/p/10062056.html
Copyright © 2011-2022 走看看