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之道11

    day11作业 请写出下列代码的执行结果: 例一: def func1(): print(**'in func1'**) def func2(): print(**'in func2'**) ret ...

  2. HTML5中Web存储

    HTML5 中web存储是一个比cookies更好的一个本地存储方式. 那么什么是HTML5存储呢? 使用HTML5可以在本地存储用户浏览的数据,HTML5技术没有出来之前是使用cookies进行本地 ...

  3. 01_8_session

    01_8_session 1. session总结 1.1服务器的一块内存(存key-value) 1.2和客户端窗口对应(子窗口)(独一无二) 1.3客户端和服务器有对应的SessionID 1.4 ...

  4. 文件下载(NSURLConnection/NSURLSession)

    最基本的网络文件下载(使用原生的网络请求) #pragma mark - 小文件下载 // 方法一: NSData dataWithContentsOfURL - (void)downloadFile ...

  5. IOS中将颜色转换为image

    - (UIImage *)createImageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f ...

  6. ARC中__weak;__strong;__unsafe_unretained;修饰词

    测试代码: // Human.h代码 @interface Human : NSObject @property (nonatomic, weak) Cat *pinkCat; @property ( ...

  7. 监测UITextField的变化

    监测UITextField的变化可以为UIControlEventEditingChanged事件添加target. 我们有时候会需要用到这个需求:输入框输入文本超过xx长度,不再允许输入其他内容! ...

  8. rest_framework之status HTTP状态码

    Django Rest Framework有一个status.py的文件 通常在我们Django视图(views)中,HTTP状态码使用的是纯数字,像400,404,200,304等,并不是那么很好理 ...

  9. python入门:用户登录,三次错误机会

    #!/usr/bin/env python # -*- coding:utf-8 -*- #用户登录,三次机会重试 #主要分为两个部分,一部分是写三次循环,一部分写用户输入 #用户登录的实现,循环3次 ...

  10. mysql 编程初步

    mysql 编程 基本语法形式: 语句块模式 [begin_label] begin [statement_list] end [end_label]; label 标识符可以省略,但必须相同 流程控 ...