D. Vanya and Triangles

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/552/problem/D

Description

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.

Sample Input

4
0 0
1 1
2 0
2 2

Sample Output

3

HINT

题意

平面上给你n个点,然后问你能构成多少个三角形

题解:

n^3暴力跑一法就过了……

是数据太水,还是我太屌?

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-5
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//**************************************************************************************
#include<cstdio>
#include<cmath>
using namespace std;
struct point
{
int x,y;
friend int operator *(point A,point B){return A.x*B.y-A.y*B.x;}
friend point operator -(point A,point B){point C;C.x=A.x-B.x;C.y=A.y-B.y;return C;}
}p[];
int ans,n;
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
for(int i=;i<=n-;i++)
for(int j=i+;j<n;j++)
for(int k=j+;k<=n;k++)
if((p[i]-p[j])*(p[j]-p[k]))ans++;
printf("%d",ans);
return ;
}

Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题的更多相关文章

  1. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

  2. Codeforces Round #355 (Div. 2) C. Vanya and Label 水题

    C. Vanya and Label 题目连接: http://www.codeforces.com/contest/677/problem/C Description While walking d ...

  3. Codeforces Round #280 (Div. 2) A. Vanya and Cubes 水题

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  5. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  6. 暴力/进制转换 Codeforces Round #308 (Div. 2) C. Vanya and Scales

    题目传送门 /* 题意:问是否能用质量为w^0,w^1,...,w^100的砝码各1个称出重量m,砝码放左边或在右边 暴力/进制转换:假设可以称出,用w进制表示,每一位是0,1,w-1.w-1表示砝码 ...

  7. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  8. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  9. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

随机推荐

  1. Windows Server 2012 R2 设置 smtp 服务器

    Windows Server 2012/2012 R2:安装和配置 SMTP 服务器 安装 SMTP 服务器 以下是安装 SMTP 服务器功能的步骤: 打开“服务器管理器”:单击键盘上的 Window ...

  2. SoapUI Property

    1. Test Suite(Case) Property 选择Test Suite(Case),switch to Custom properties 在request中的引用方式: ${[scope ...

  3. jQuery 关于点击菜单项,使子条目“向上”展开效果的实现

    为什么做了这样一个的功能呢?原因是前一段时间jQuery群里有个朋友想实现这样一个东东,大家都知道jQuery中有现成的slideDown和slideUp方法,但那是向下展开,而这个是一个完全相反的效 ...

  4. 配置Texmaker中文支持

    在Ubuntu 12.04 LTS下安装Texmaker后,如需要支持中文环境,需要安装CJK包. 终端(Ctrl+Alt+T(Terminal))下输入命令切换到超级管理员: sudo -i 安装包 ...

  5. 在 Asp.NET MVC 中使用 SignalR 实现推送功能

    一,简介Signal 是微软支持的一个运行在 Dot NET 平台上的 html websocket 框架.它出现的主要目的是实现服务器主动推送(Push)消息到客户端页面,这样客户端就不必重新发送请 ...

  6. python 抽象类、抽象方法的实现

    由于python 没有抽象类.接口的概念,所以要实现这种功能得abc.py 这个类库,具体方式如下 from abc import ABCMeta, abstractmethod #抽象类 class ...

  7. HW7.17

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  8. 从数列1,2,3.......n 中 随意取几个数,使其和等于 m

    //从数列1,2,3.......n 中 随意取几个数,使其和等于 m           public static void Print(int n, int m, List<int> ...

  9. 转】腾讯云CentOS 6.6安装 Nginx

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/5290155.html 感谢! 一.下载Nginx 从Nginx的官网(http://nginx.org/en/d ...

  10. 【转】MySQL日期时间函数大全

    MySQL日期时间函数大全 1.DAYOFWEEK(date)  返回日期date是星期几(1=星期天,2=星期一,……7=星期六,ODBC标准)mysql> select DAYOFWEEK( ...