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之文件操作的初识

    1. 操作文件 1.1 操作的方法 f = open("文件路径",mode="模式",encoding="编码") open() # 调用 ...

  2. JavaScript -- DOM事件

    什么是事件 事件就是文档或浏览器窗口中发生的一些特定的交互瞬间.比如你在网页上见到的鼠标点击一个按钮,按钮的颜色发生了变化,就是因为这个标签绑定了点击事件 鼠标事件 onload:页面加载时触发 on ...

  3. Makefile 编写实例

    make命令常用的三个选项: 1.-k:它的作用是让make命令在发现错误的时候仍然继续执行.我们可以利用这个选项在一次操作中发现未编译成功的源文件. 2.-n:它的作用是让make命令输出将要执行的 ...

  4. java,求1-100之和。

    package study01; public class TestWhile { public static void main(String[] args) { int sum = 0; int ...

  5. ubuntu 16.04下如何打造 sublime python编程环境

    一.安装python3     ubuntu自身是安装python2的,例如在ubuntu 16.04中安装的就是python2.7.但我想在python3的环境下进行开发所以就要安装python3. ...

  6. Applied Nonparametric Statistics-lec8

    Ref:https://onlinecourses.science.psu.edu/stat464/print/book/export/html/11 additive model value = t ...

  7. AD采样求平均STM32实现

    iADC_read(, &u16NTC_1_Sample_Val_ARR[]); == ui8FirstSampleFlag) { ; i<; i++) { u16NTC_1_Sampl ...

  8. Divisibility by 25 CodeForces - 988E

    You are given an integer nn from 11 to 10181018 without leading zeroes. In one move you can swap any ...

  9. poj-2533 longest ordered subsequence(动态规划)

    Time limit2000 ms Memory limit65536 kB A numeric sequence of ai is ordered if a1 < a2 < ... &l ...

  10. 官网下载MySQL

    1)首先我们访问MySQL官网https://dev.mysql.com/,然后如下 2)我们向下拉取滚动条,来到如下界面,选择Source Code 3)向下拉取滚动条,来到如下界面,操作如下: 4 ...