zoukankan      html  css  js  c++  java
  • ACM: FZU 2110 Star

     FZU 2110  Star
    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    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

    求锐角三角形的个数;

    数学结论 : 锐角三角形 任意边满足 a^2<b^2+c^2 ;

    AC代码:

    #include"algorithm"
    #include"iostream"
    #include"cstring"
    #include"cstdlib"
    #include"cstdio"
    #include"string"
    #include"vector"
    #include"stack"
    #include"queue"
    #include"cmath"
    #include"map"
    using namespace std;
    typedef long long LL ;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define FK(x) cout<<"["<<x<<"]
    "
    #define memset(x,y) memset(x,y,sizeof(x))
    #define memcpy(x,y) memcpy(x,y,sizeof(x))
    #define bigfor(T)  for(int qq=1;qq<= T ;qq++)
    
    struct Star {
    	LL x;
    	LL y;
    } st[200];
    
    bool cmp(LL a,LL b) {
    	return a>b;
    }
    
    bool check(int i,int j,int k) {
    	LL s[3];
    	s[0]=(st[i].x-st[j].x)*(st[i].x-st[j].x)+(st[i].y-st[j].y)*(st[i].y-st[j].y);
    	s[1]=(st[i].x-st[k].x)*(st[i].x-st[k].x)+(st[i].y-st[k].y)*(st[i].y-st[k].y);
    	s[2]=(st[k].x-st[j].x)*(st[k].x-st[j].x)+(st[k].y-st[j].y)*(st[k].y-st[j].y);
    //	FK(s[0]);
    //	FK(s[1]);
    //	FK(s[2]);
    	sort(s,s+3,cmp);
    	if(s[0]<s[1]+s[2])return 1;
    	return 0;
    }
    
    int main() {
    	int T;
    	int n;
    	scanf("%d",&T);
    	bigfor(T) {
    		scanf("%d",&n);
    		for(int i=0; i<n; i++) {
    			scanf("%I64d%I64d",&st[i].x,&st[i].y);
    		}
    		LL ans=0;
    		for(int i=0; i<n; i++) {
    			for(int j=i+1; j<n; j++) {
    				for(int k=j+1; k<n; k++) {
    					if(check(i,j,k)) ans++;
    				}
    			}
    		}
    		printf("%I64d
    ",ans);
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    Android SDK Manager 无法下载更新,或者更新速度超慢,或者待安装包列表不显示
    window 下Qt for android 环境搭建
    vim 编辑器的设置
    用户登录案例 展示 三层架构
    简单的SqlHelper
    利用webclient ftpclient上传下载文件
    绑定省市到treeview 递归加载 递归删除
    MD5 文件和字符传加密
    MVC4 EF5.0 实现异步删除和修改 easyui
    MVC中应用ajax的两种方式
  • 原文地址:https://www.cnblogs.com/HDMaxfun/p/5789480.html
Copyright © 2011-2022 走看看