Problem 2110 Star

Accept: 996    Submit: 2958
Time Limit: 1000 mSec    Memory Limit : 32768
KB

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

 
题意:平面上有n个点,由这n个点中任意三个都可以组成一个三角形,问总共有多少种组合使得得到的三角形的锐角三角形。
思路:穷竭搜索,判断每一种组合下得到的三角形是否为锐角即可,判断锐角的方式:设所要判断的角的两边分别为a,b,斜边c,若a^2+b^2>c^2,即可判断该角为锐角,建立坐标系解析该式,设三角形三顶点的坐标为(x1,y1),(x2,y2),(x3,y3),代入前式化简得
(x1-x2)*(x1-x3)+(y1-y2)*(y1-y3)>0即可。
AC代码:

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int N_MAX = + ;
int n;
ll x[N_MAX], y[N_MAX]; bool judge(int i,int j,int k) {
return (x[i] - x[j])*(x[i] - x[k]) + (y[i] - y[j])*(y[i] - y[k])>;
} int main() {
int T;
scanf("%d",&T);
while (T--) {
scanf("%d",&n); for (int i = ; i < n;i++) {
scanf("%lld%lld",&x[i],&y[i]);
}
int num = ;
for (int i = ; i < n;i++) {
for (int j = +i; j < n;j++) {
for (int k = j + ; k < n;k++) {
if (judge(i, j, k) && judge(j, i, k) && judge(k, i, j)) {
num++;
}
}
}
}
printf("%d\n",num);
}
return ;
}

FZOJ Problem 2110 Star的更多相关文章

  1. ACM: FZU 2110 Star - 数学几何 - 水题

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

  2. FZOJ Problem 2219 StarCraft

                                                                                                        ...

  3. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

  4. FZOJ Problem 2150 Fire Game

                                                                                                        ...

  5. FZOJ Problem 2148 Moon Game

                                                                                                  Proble ...

  6. FZOJ Problem 2107 Hua Rong Dao

                                                                                                        ...

  7. FZOJ Problem 2103 Bin & Jing in wonderland

                                                                                                        ...

  8. FZU 2110 Star

    简单暴力题,读入%lld会WA,%I64d能过. #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  9. Codeforces Round #427 (Div. 2) [ C. Star sky ] [ D. Palindromic characteristics ] [ E. The penguin's game ]

    本来准备好好打一场的,然而无奈腹痛只能带星号参加 (我才不是怕被打爆呢!) PROBLEM C - Star sky 题 OvO http://codeforces.com/contest/835/p ...

随机推荐

  1. python之道13

    看代码分析结果 func_list = [] for i in range(10): func_list.append(lambda :i) v1 = func_list[0]() v2 = func ...

  2. LiteIDE 错误: go build xxxxxx: no non-test Go files in xxxx

    问题 c:/go/bin/go.exe build [C:/Users/Administrator/Desktop/go] go build _/C_/Users/Administrator/Desk ...

  3. d3.js--02(data和datum原理)

    原文链接: http://d3.decembercafe.org/pages/lessons/3.html 解析一下data和datum原理: datum():绑定一个数据到选择集上 data():绑 ...

  4. EditPlus 比较完整的快捷键记录

    FileFtpUpload Ctrl+Shift+S 上传文件到FTP 服务器 FileNew Ctrl+N 新建普通的文本文档 FileNewHtml Ctrl+Shift+N 创建一个空白的 HT ...

  5. python多进程并发进程池Pool

    简介: python中的多进程主要使用到 multiprocessing 这个库.低版本python这个库在使用 multiprocessing.Manager().Queue时会出问题,建议大家升级 ...

  6. leetcode-25-exercise_string&array

    14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array ...

  7. leetcode-17-BST

    530. Minimum Absolute Difference in BST Given a binary search tree with non-negative values, find th ...

  8. [转] vuex最简单、最直白、最全的入门文档

    前言 我们经常用element-ui做后台管理系统,经常会遇到父组件给子组件传递数据,下面一个简单的例子,点击按钮,把弹框显示变量数据通过子组件的props属性传递,子组件通过$emit事件监听把数据 ...

  9. EXCEL宏做数据拆分

    用处:将大容量的EXCEL工作簿分解成若干个小的工作簿 Sub aa() For i = 1 To 8 Set nb = Workbooks.Add nb.SaveAs Filename:=ThisW ...

  10. loj2182 「SDOI2015」寻宝游戏

    参考这里 #include <iostream> #include <cstdio> #include <set> using namespace std; typ ...