time limit per test4 seconds

memory limit per test512 megabytes

inputstandard input

outputstandard output

Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.

Input

The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane.

Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.

Output

In the first line print an integer — the number of triangles with the non-zero area among the painted points.

Examples

input

4

0 0

1 1

2 0

2 2

output

3

input

3

0 0

1 1

2 0

output

1

input

1

1 1

output

0

Note

Note to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).

Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).

Note to the third sample test. A single point doesn’t form a single triangle.

【题目链接】:http://codeforces.com/contest/552/problem/D

【题解】



时限给的宽。

直接暴力枚举就可以了。

判断3条线是否相交

O(N^3);

1500MS过。。

MAXN=2000;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int MAXN = 2e3+100;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); struct abc
{
int x,y;
}; int n;
abc a[MAXN]; bool xj(int t1,int t2,int t3)
{
int x1 = a[t1].x,y1 = a[t1].y;
int x2 = a[t2].x,y2 = a[t2].y;
int x3 = a[t3].x,y3 = a[t3].y;
if ((x2-x1)*(y3-y2)-(y2-y1)*(x3-x2)==0) return true;
else
return false;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(i,1,n)
rei(a[i].x),rei(a[i].y);
LL ans = 0;
rep1(i,1,n-2)
rep1(j,i+1,n-1)
rep1(k,j+1,n)
if (!xj(i,j,k))
ans++;
printf("%I64d\n",ans);
return 0;
}

【25.33%】【codeforces 552D】Vanya and Triangles的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. codeforces#552 D. Vanya and Triangles(几何)

    题意:给出n个不同的点,问能组成多少个不同的三角形 题解:对于每个点对,我们生成一个直线,用a*x+b=y表示,用map记录ab,这样就确定了一个直线,这样我们就能算出有多少点是共线的,这样复杂度就是 ...

  3. 【23.33%】【codeforces 557B】Pasha and Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【33.10%】【codeforces 604C】Alternative Thinking

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【25.64%】【codeforces 570E】Pig and Palindromes

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【33.33%】【codeforces 552B】Vanya and Books

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【25.00%】【codeforces 584E】Anton and Ira

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【33.33%】【codeforces 586D】Phillip and Trains

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【33.33%】【codeforces 608C】Chain Reaction

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. BZOJ3672: [Noi2014]购票(CDQ分治,点分治)

    Description  今年夏天,NOI在SZ市迎来了她30周岁的生日.来自全国 n 个城市的OIer们都会从各地出发,到SZ市参加这次盛会.        全国的城市构成了一棵以SZ市为根的有根树 ...

  2. 【习题 7-9 UVA-1604】Cubic Eight-Puzzle

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] IDA* 保证这次移动的方格不和前一次重复. 然后加一个8数码的剪枝就行了. ->看看当前状态和目标状态有多少个地方是不一样的 ...

  3. 【习题 7-4 UVA-818】Cutting Chains

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 二进制枚举要解开哪些环. 把所有和它相关的边都删掉. 对于剩下的联通分量. 看看是不是每一个联通分量都是一条链 ->每个点的度 ...

  4. 洛谷 P2562 [AHOI2002]Kitty猫基因编码

    P2562 [AHOI2002]Kitty猫基因编码 题目描述 小可可选修了基础生物基因学.教授告诉大家 Super Samuel 星球上 Kitty猫的基因的长度都是 2 的正整数次幂 ), 全是由 ...

  5. [React] Remove React PropTypes by using Flow Annotations (in CRA)

    Starting from v15.5 if we wanted to use React's PropTypes we had to change our code to use a separat ...

  6. 第一个Python程序(全面)

    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 一.Windows系统 1.编写Python程序方式之Sublime文本编辑器: 1>打开sublime,创建hello.p ...

  7. 【Codeforces Round #301 (Div. 2) E】Infinite Inversions

    [链接] 我是链接,点我呀:) [题意] 给你一个无限长的序列1,2,3,4... 然后给你n个操作. 每个操作ai,bi; 表示调换位置为ai和位置为bi的数的位置. (ai,bi<=10^9 ...

  8. [AngularJS] Interpolation fail in IE 11

    When you occured this problem, check few things: For the input field, use // Use ng-attr-placeholder ...

  9. Windows下安装Resin及配置具体解释与公布应用

        关于Resin的优点,网上介绍了一大堆.小编经不住诱惑,决定试用一下. 眼下Resin的最新版本号为:4.0.40.能够从官网直接下载.     1. 将下载下来的Resin包解压开,会看到一 ...

  10. 每日技术总结:setInterval,setTimeout,文本溢出,小程序,wepy

    前言: 项目背景:vue,电商,商品详情页 1.倒计时,倒计到0秒时停止 data () { return { n: 10 } }, created () { let int = setInterva ...