hdu2150 & hdu2288 &hdu2393

几何基础题。

hdu2150.
题目链接:点这里
题意:略。
思路。枚举每两个线段。
AC代码:

/*=========================================================================
#
# Author: renchengqian
#
# QQ : 1029184180
#
# Last modified:    2016-09-23 10:06
#
# Filename:     1.cpp
#
# Description:
#
==========================================================================*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
struct point {
    double x,y;
    point (double x = 0,double y = 0) {}
};
struct Line{
    point a,b;
};
Line line[4000];
int f[1010];
point p[4000];
int dcmp(double x) {
    if(fabs(x)-0 < eps) return 0;
    else if(x > 0) return 1;
    else return -1;
}
double cross(point a,point b,point c) {
    if(dcmp((b.x-a.x)*(c.y-a.y) - (c.x-a.x)*(b.y-a.y)) == 0) return 0;
    return ((b.x-a.x)*(c.y-a.y) - (c.x-a.x)*(b.y-a.y));
}
bool pd(point a,point b,point c,point d) {
        if(min(a.x,b.x) <= max(c.x,d.x) && min(c.x,d.x)<=max(a.x,b.x) &&
           min(a.y,b.y) <= max(c.y,d.y) && min(c.y,d.y)<=max(a.y,b.y)){
                if(cross(a,b,c)*cross(a,b,d) <= 0 && cross(d,c,a)*cross(d,c,b) <= 0) {
                   return 1;
                }
           }
        return 0;
}
int main(){
    int n;
    while(scanf("%d",&n)!=EOF) {
        int tot = 0,indx = 0;
        memset(f,0,sizeof(f));
        int k;
        for(int i=1;i<=n;i++) {
            scanf("%d",&k);
            tot = 0;
            ++tot;
            scanf("%lf%lf",&p[tot].x,&p[tot].y);
            for(int j=2; j<=k; j++) {
                ++tot;
                scanf("%lf%lf",&p[tot].x,&p[tot].y);
                line[++indx].a = p[tot-1];
                line[indx].b = p[tot];
                f[indx] = i;
            }
        }
//        for(int i=1;i<=indx; i++) {
//            printf("%lf %lf %lf %lf\n",line[i].a.x,line[i].a.y,line[i].b.x,line[i].b.y);
//        }cout<<endl;
        int F = 0;
        for(int i=1;i<indx; i++) {
            for(int j=i+1; j<=indx; j++) {
                if(f[i] == f[j]) continue;
                if(pd(line[i].a,line[i].b,line[j].a,line[j].b)) {
                    F = 1; break;
                }
            }
        }
        if(F) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

hdu2288
题目链接:点这里
题意:把漏斗的水放进下面盒子里,求盒子水的高度。
思路:略。
AC代码:

/*==========================================================================
#
# Author: renchengqian
#
# QQ : 1029184180
#
# Last modified:    2016-09-23 09:25
#
# Filename:        1.cpp
#
# Description:
#
==========================================================================*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);

int main(){
    double x,y,z,h,d;
    while(scanf("%lf%lf%lf%lf%lf",&x,&y,&z,&h,&d)!=EOF) {
        if(x == 0 && y==0 && z==0 && h==0 && d==0) break;
        double S1 = PI*(x*x/4);
        double S2 = PI*(y*y/4);
        double M = (S1+S2+sqrt(S1*S2))*z/3.0;
        if(M > (d*d*h)) {
            printf("%.3lf\n",h);
        }else
        printf("%.3lf\n",M/d/d);
    }
    return 0;
}

hdu2393
题目链接: 点这里
题意:能否组成直角三角形
思路:略。

/*==========================================================================
#
# Author: renchengqian
#
# QQ : 1029184180
#
# Last modified:    2016-09-23 09:08
#
# Filename:        1.cpp
#
# Description:
#
==========================================================================*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
int F(int a,int b,int c) {
    if(a<b) swap(a,b);
    if(a<c) swap(a,c);
    if(a*a == b*b+c*c) return 1;
    else return 0;
}
int main(){
    int t; scanf("%d",&t);
    for(int cas = 1; cas<=t; cas++) {
        int a,b,c; scanf("%d%d%d",&a,&b,&c);
        printf("Scenario #%d:\n",cas);
        if(F(a,b,c)) {
            printf("yes\n");
        }else {
            printf("no\n");
        }
        printf("\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值