枚举法:

枚举法是利用计算机速度快, 精度高的特点, 对要解决的问题所有可能情况进行霸道的, 一个不漏检验, 从中找出符合要求的答案。

特点:

1. 得到的结果一定正确。

2. 可能做了很多无用功,效率低下。

3. 一般会涉及到极值。

4. 数据量大的话可能造成时间崩溃。

结构:

循环结构。

基本思路:

1. 确定枚举对象, 枚举范围, 判定条件。

2. 枚举可能的解, 验证是否是问题的解。

Vanya and Triangles :

M - Vanya and Triangles

Crawling in process... Crawling failed Time Limit:4000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u

SubmitStatus

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

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

 
 
#include<stdio.h>

struct point{
int x, y;
}p[3100]; int main()
{
int n, ans = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d%d", &p[i].x, &p[i].y);
for(int i = 1; i < n - 1; i++)
for(int j = i + 1; j < n; j++)
for(int k = j + 1; k <=n; k++)
if((p[i].y - p[j].y)*(p[k].x - p[i].x) != (p[k].y - p[i].y)*(p[i].x - p[j].x))
ans++;
printf("%d\n", ans);
return 0;
}

  

  

 

Vanya and Triangles 暴力枚举的更多相关文章

  1. Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题

    D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...

  2. Codeforces 552E Vanya and Brackets(枚举 + 表达式计算)

    题目链接 Vanya and Brackets 题目大意是给出一个只由1-9的数.乘号和加号组成的表达式,若要在这个表达式中加上一对括号,求加上括号的表达式的最大值. 我们发现,左括号的位置肯定是最左 ...

  3. hdu 4082 Hou Yi's secret(暴力枚举)

    Hou Yi's secret Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  5. 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)

    /* 将给定的一个字符串分解成ABABA 或者 ABABCAB的形式! 思路:暴力枚举A, B, C串! */ 1 #include<iostream> #include<cstri ...

  6. HNU 12886 Cracking the Safe(暴力枚举)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...

  7. 51nod 1116 K进制下的大数 (暴力枚举)

    题目链接 题意:中文题. 题解:暴力枚举. #include <iostream> #include <cstring> using namespace std; ; ; ch ...

  8. Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举

    题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...

  9. bzoj 1028 暴力枚举判断

    昨天梦到这道题了,所以一定要A掉(其实梦到了3道,有两道记不清了) 暴力枚举等的是哪张牌,将是哪张牌,然后贪心的判断就行了. 对于一个状态判断是否为胡牌,1-n扫一遍,然后对于每个牌,先mod 3, ...

随机推荐

  1. redis-2.6.16源码分析之pub-sub系统

    redis实现的发送订阅系统,即pub-sub,这部分的的代码比较少,也方便分析.在这只将会分析下普通的pub-sub(会忽略掉Pattern-matching subscriptions),以此来简 ...

  2. [Docker] Docker Machine intro

    List all the docker machine: docker-machine ls Can check 'ip' and 'status': docker-machine ip defaul ...

  3. Android 连接Wifi和创建Wifi热点 demo

    android的热点功能不可见,用了反射的技术搞定之外. Eclipse设置语言为utf-8才能查看中文注释 上代码: MainActivity.java package com.widget.hot ...

  4. Windows与自定义USB HID设备通信说明.

    1 .   所使用的典型 Windows API CreateFile ReadFile WriteFile 以下函数是 DDK 的内容: HidD_SetFeature HidD_GetFeatur ...

  5. svn不提交user文件

    http://godera.blog.163.com/blog/static/215023060201312011112966/

  6. SQL 去除小数点后无效 0 的方法

     select convert(float,10.0000)  就是这么简单

  7. 在公网上布署Web Api的时候,不能调用,返回404

    在internet上布署web API做的站点时,发现不能调用web api的任何action, 返回404. 经过很多的努力,也找不到原因,环境是win server 2008, IIS 75. n ...

  8. 沙盒操作的核心函数 - NSSearchPathForDirectoriesInDomains用法

    1. iPhone会为每一个应用程序生成一个私有目录,这个目录位于: /Users/sundfsun2009/Library/Application Support/iPhone Simulator/ ...

  9. asp.net执行cmd命令(包括第三方应用的命令行)

    Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = ...

  10. php 求两个文件的相对路径

    网上看了一些这个题的一些解答方法,不过大多数就是对目前需求而定的,比如 $a = '/a/b/c/d/e.php'; $b = '/a/d/12/34/c.php'; getpath($a , $b ...