zoukankan      html  css  js  c++  java
  • FZOJ2110: Star

    Problem Description

    Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower’s classmates ask him: “How many acute triangles whose inner angles are less than 90 degrees (regarding stars as points) can be found? Assuming all the stars are in the same plane”. Please help him to solve this problem.

    Input

    The first line of the input contains an integer T (T≤10), indicating the number of test cases.

    For each test case:

    The first line contains one integer n (1≤n≤100), the number of stars.

    The next n lines each contains two integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points are distinct.

    Output

    For each test case, output an integer indicating the total number of different acute triangles.

    Sample Input

    1
    3
    0 0
    10 0
    5 1000

    Sample Output

    1

    题意:每个样例给出n,然后n个坐标,求这些点能组成多少个锐角三角形

    思路:只要知道锐角三角形三边的关系a^2+b^2>c^2即可

    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    
    int main()
    {
    	double a[2][105],x,y,z;
    	int i,j,k,ans,n,t,flag1,flag2,flag3;
    	scanf("%d",&t);
    	while(t--)
    	{
    		scanf("%d",&n);
    		for(i = 0;i<n;i++)
    			scanf("%lf%lf",&a[0][i],&a[1][i]);
    		ans = 0;
    		for(i = 0;i<n-2;i++)
    		{
    			for(j = i+1;j<n-1;j++)
    			{
    				for(k = j+1;k<n;k++)
    				{
    					flag1 = flag2 = flag3 = 0;
    					x = sqrt((a[0][i]-a[0][j])*(a[0][i]-a[0][j])+(a[1][i]-a[1][j])*(a[1][i]-a[1][j]));
    					y = sqrt((a[0][i]-a[0][k])*(a[0][i]-a[0][k])+(a[1][i]-a[1][k])*(a[1][i]-a[1][k]));
    					z = sqrt((a[0][k]-a[0][j])*(a[0][k]-a[0][j])+(a[1][k]-a[1][j])*(a[1][k]-a[1][j]));
    					if(x*x+y*y>z*z)
    						flag1 = 1;
    					if(y*y+z*z>x*x)
    						flag2 = 1;
    					if(x*x+z*z>y*y)
    						flag3 = 1;
    					if(flag1 && flag2 && flag3)
    						ans++;
    				}
    			}
    		}
    		printf("%d
    ",ans);
    	}
    
    	return 0;
    }
    


     

  • 相关阅读:
    SVN——Jenkins自动发布
    IIS之虚拟目录学习
    SVN迁移
    通过配置host,自定义域名让本地访问
    比较两个时间的大小 举例:CompareDate("12:00","11:15")
    [转]SQL Server 批量完整备份
    js前台编码,asp.net后台解码 防止前台传值到后台为乱码
    前端将图片二进制流显示在html端
    【转】解析<button>和<input type="button"> 的区别
    利用bat批处理——实现数据库的自动备份和删除
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3244057.html
Copyright © 2011-2022 走看看