#include<bits/stdc++.h>
using namespace std;
typedef struct{
 double k,b;
}node;
node k[1000007];
bool cmp(node&a,node&b){
 if(a.k==b.k)
  return a.b<b.b;
 return a.k<b.k;
}
long long x[1007],y[1007];
int main(){
 long long n,ans=0,tot=0;
 scanf("%lld",&n);
 for(long long i=1;i<=n;++i)
  scanf("%lld%lld",&x[i],&y[i]);
 for(long long i=1;i<=n;++i){
  for(long long j=1;j<i;++j){
   if(x[i]!=x[j])
    k[++tot].k=(y[i]-y[j])*1.0/(x[i]-x[j]),k[tot].b=y[i]-x[i]*k[tot].k;
   else
    k[++tot].b=x[i],k[tot].k=1000000;
  }
 }
 sort(k+1,k+1+tot,cmp);
 long long i=1;
 for(long long i=tot;i>=1;--i)
  if(k[i].k==k[i-1].k&&k[i].b==k[i-1].b)
   k[i].k=10000000;
 sort(k+1,k+1+tot,cmp);
 for(long long i=1;i<=tot;++i)
  if(k[i].k==10000000){
   tot=i-1;
   break;
  }
 while(i<=tot){
  long long x=i;
  while(k[i].k==k[i+1].k)
   i++;
  ans+=(i-x+1)*(x-1);
  i++;
 }
 cout<<ans;
 return 0;
}

Codeforces Round #558 (Div. 2)C(计算几何,排列组合,模拟)的更多相关文章

  1. Codeforces Round #558 (Div. 2)B(SET,模拟)

    #include<bits/stdc++.h>using namespace std;int a[100007];int cnt[100007];int main(){    int n; ...

  2. Codeforces Round #558 (Div. 2)

    目录 Codeforces Round #558 (Div. 2) 题解 A Eating Soup B Cat Party C Power Transmission D Mysterious Cod ...

  3. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

  4. CodeCraft-19 and Codeforces Round #537 (Div. 2) D 多重排列 + 反向01背包 + 离线处理

    https://codeforces.com/contest/1111/problem/D 多重排列 + 反向01背包 题意: 给你一个字符串(n<=1e5,n为偶数),有q个询问,每次询问两个 ...

  5. Codeforces Round #558 (Div. 2)-Cat Party (Hard Edition)-(前缀和 + 模拟)

    http://codeforces.com/problemset/problem/1163/B2 题意:有n天,每天有一个颜色,截取前x天,随便抽掉一天,使剩下的各个颜色出现的次数相等. 解题,也可以 ...

  6. Codeforces Round #357 (Div. 2) E 计算几何

    传说中做cf不补题等于没做 于是第一次补...这次的cf没有做出来DE D题的描述神奇 到现在也没有看懂 于是只补了E 每次div2都是hack前2~3题 终于打出一次hack后的三题了...希望以后 ...

  7. Codeforces Round 558(Div 2)题解

    这场比赛没有打,后来和同学们一起开了场镜像打…… B是SB题结果WA了5发…… C是SB题结果差5min调出……虽然中间有个老师讲题吃掉了1h D是比较神仙的题(2200),但是做出来了?算是比较超常 ...

  8. Codeforces Round #379 (Div. 2) D. Anton and Chess 模拟

    题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmem ...

  9. Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟

    B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

随机推荐

  1. IDEA 安装完码云插件,运行报“Cannot run program "xxx":CreateProcess error=2,系统找不到指定的文件”

    错误:Cannot run program "E:\Program Files\Git\bin\git.exe":CreateProcess error=2,系统找不到指定的文件 ...

  2. python-管理MySQL之ConfigParser模块

    1.拷贝2.7版本的ConfigParser.py模块支持无值解析 cp /usr/local/src/Python-2.7.5/Lib/ConfigParser.py /usr/lib/python ...

  3. 2_flyweight, 轻量化模式

    ### instanced rendering. send shared data to gpu just once mesh, texture, leaves push every instance ...

  4. leetcode 6 ZigZag Conversion(水题)

    就是简单的模拟一下就可以了.但是我一开始是用一个二维char数组来存的,这样在最终扫全体时会扫很多空的位置,浪费了很多时间,所以就time limit error了. 所以改进一下就用string数组 ...

  5. 使用WindowsAPI实现播放PCM音频的方法

    这篇文章主要介绍了使用WindowsAPI实现播放PCM音频的方法,很实用的一个功能,需要的朋友可以参考下 本文介绍了使用WindowsAPI实现播放PCM音频的方法,同前面一篇使用WindowsAP ...

  6. 线段树_区间加乘(洛谷P3373模板)

    题目描述 如题,已知一个数列,你需要进行下面三种操作: 1.将某区间每一个数乘上x 2.将某区间每一个数加上x 3.求出某区间每一个数的和 输入格式: 第一行包含三个整数N.M.P,分别表示该数列数字 ...

  7. 系列文章--突袭HTML5之Javascript

    突袭HTML5之Javascript API扩展5 - 其他扩展 突袭HTML5之Javascript API扩展4 - 拖拽 突袭HTML5之Javascript API扩展3 - 本地存储 突袭H ...

  8. 洛谷【P1080】国王游戏

    我对贪心的理解:https://www.cnblogs.com/AKMer/p/9776293.html 题目传送门:https://www.luogu.org/problemnew/show/P10 ...

  9. win32 获取 HotKey 控件中的内容(HKM_GETHOTKEY)

    windows给我们提供了一个对话框控件HotKey非常好用,在设置热键的时候用起来很爽,但是一直百度就是没找到在win32下怎样通过消息获取这个控件里面的内容,找到的都是用MFC封装好的控件类来操作 ...

  10. poj 2388 Who's in the Middle(快速排序求中位数)

    一.Description FJ is surveying his herd to find the most average cow. He wants to know how much milk ...