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\n"); 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\n"); flag=1; break; } } if(!flag) printf("No\n"); } return 0; }