3493. 【NOIP2013模拟联考13】三角形(triangle) 
(File IO): input:triangle.in output:triangle.out

Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits  

Goto ProblemSet

Description

平面上有n个点,求出用这些点可以构成的三角形数。
 

Input

第一行一个整数n。

接下来n行,每行两个整数,表示点的坐标。

Output

输出仅一个整数,表示所求答案。
 

Sample Input

5
0 0
1 1
1 -1
-1 -1
-1 1

Sample Output

8
 

Data Constraint

对于50%的数据,n<=300。

对于100%的数据,n<=3000,坐标的绝对值不超过10^4,保证没有重合的点。

 
做法:确定第一个点,枚举直线,判断不能形成三角形的情况,斜率不存在时要特判。
 
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 3007
using namespace std;
int n, h[N], z[N], tot, cnt, c[N * ];
long long ans;
bool b[N];
double K[N]; int main()
{
// freopen("triangle.in", "r", stdin);
// freopen("triangle.out", "w", stdout);
scanf("%d", &n);
for (int i = ; i <= n; i++)
scanf("%d%d", &h[i], &z[i]);
ans = (n * (n - )) / ;
ans *= n - ;
ans /= ;
for (int i = ; i <= n - ; i++)
{
cnt = ;
tot = ;
for (int j = i + ; j <= n; j++)
if (h[i] == h[j]) tot++;
else K[++cnt] = (double)(z[i] - z[j]) / (double)(h[i] - h[j]);
sort(K + , K + cnt + );
ans -= (tot * (tot - )) / ;
tot = ;
for (int j = ; j <= cnt; j++)
{
if (K[j] == K[j - ]) tot++;
else tot = ;
ans -= tot - ;
}
}
printf("%lld", ans);
fclose(stdin);
fclose(stdout);
}

JZOJ 3493. 【NOIP2013模拟联考13】三角形的更多相关文章

  1. JZOJ【NOIP2013模拟联考14】隐藏指令

    JZOJ[NOIP2013模拟联考14]隐藏指令 题目 Description 在d维欧几里得空间中,指令是一个长度为2N的串.串的每一个元素为d个正交基的方向及反方向之一.例如,d = 1时(数轴) ...

  2. JZOJ 3487. 【NOIP2013模拟联考11】剑与魔法(dragons)

    3487. [NOIP2013模拟联考11]剑与魔法(dragons) (Standard IO) Time Limits: 1000 ms  Memory Limits: 131072 KB  De ...

  3. JZOJ 3470. 【NOIP2013模拟联考8】最短路(path)

    470. [NOIP2013模拟联考8]最短路(path) (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed ...

  4. JZOJ 3463. 【NOIP2013模拟联考5】军训

    3463. [NOIP2013模拟联考5]军训(training) (Standard IO) Time Limits: 2000 ms  Memory Limits: 262144 KB  Deta ...

  5. JZOJ 3462. 【NOIP2013模拟联考5】休息(rest)

    3462. [NOIP2013模拟联考5]休息(rest) (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed ...

  6. JZOJ 3461. 【NOIP2013模拟联考5】小麦亩产一千八(kela)

    3461. [NOIP2013模拟联考5]小麦亩产一千八(kela) (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB  Det ...

  7. 【NOIP2013模拟联考7】OSU

    [NOIP2013模拟联考7]OSU 描述 Description osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: 一共有n次操作,每次操作只有成功与失败之分, ...

  8. [jzoj]3468.【NOIP2013模拟联考7】OSU!(osu)

    Link https://jzoj.net/senior/#main/show/3468 Description osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: ...

  9. [jzoj]3456.【NOIP2013模拟联考3】恭介的法则(rule)

    Link https://jzoj.net/senior/#main/show/3456 Description 终于,在众亲们的奋斗下,最终boss 恭介被关进了库特设计的密室.正当她们松了一口气时 ...

随机推荐

  1. CheatEngine-内存修改

    0.备注+待完成 //备注 a). 如果有方括号,就是说CE认为找 到了数值的指针了 //待完成 a). 自动导出外挂 b). 菜单栏中"表单"下的lua是做什么用的 c). CE ...

  2. css相关知识

    display: block; "块级元素". display: inline; "行内元素". display: none; "在不删除元素的情况下 ...

  3. IDEA集成tomcat启动时控制台打印中文乱码

    转载:https://blog.csdn.net/nan_cheung/article/details/79337273 idea启动tomcat控制台出现乱码,每个人可能引发该问题的原因不同,可以就 ...

  4. spring ehcache 使用详解

    Spring 整合 Ehcache 管理缓存详解  yellowbutterfly 前言 Ehcache 是一个成熟的缓存框架,你可以直接使用它来管理你的缓存. Spring 提供了对缓存功能的抽象: ...

  5. 关于com工程依赖的一些总结

    作者:朱金灿 来源:http://blog.csdn.net/clever101 一是com组件工程的依赖设置.比如A这个组件工程要使用B组件工程的类,要如何设置呢?具体就是先把在A工程里加上B工程的 ...

  6. linux日常1-踢出用户

    踢掉自己不用的终端 1.查看系统在线用户 w 2.查看哪个属于此时自己的终端(我开了两个连接) who am i 3.pkill掉自己不适用的终端 pkill -kill -t pts/1 注意: 如 ...

  7. 真正理解 git fetch, git pull 以及 FETCH_HEAD(转)

    转自http://www.cnblogs.com/ToDoToTry/p/4095626.html 真正理解 git fetch, git pull 要讲清楚git fetch,git pull,必须 ...

  8. python3应用例子01(进度条)

    #!/usr/bin/env python# -*- coding:utf-8 -*- import sysimport time def bar(num, total): rate = num / ...

  9. byte[] 中需要除去的特定 byte

    /// <summary> /// 去掉byte[]中特定的byte /// </summary> /// <param name="SourceByteArr ...

  10. 工作流性能优化(敢问activiti有扩展性?)(1)

    工作流待办(首页待办列表),加载缓慢,activiti本机,看了代码又是全部数据加载到内存,然后代码过滤,我为什么又说又呢? 用VisualVM做性能测试:   之前同事给的解决方案: 1.把&quo ...