#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. 理解javascript this 值

    如何确定this的值 this值会被传递给所有函数,this的值是基于运行时调用函数的上下文. 例如:从全局作用域调用sayFoo函数时,this引用window对象 当它作为myObject的一种方 ...

  2. 【海量之道】海量之道之SET模型

    本文介绍了set模型. 一 提供海量服务时面对的场景 场景1:如何令黄村机房的TWS机器访问黄村机房的APP服务,避免TWS跨机房调用永丰机房的APP机器? 场景2:DB和Redis如何实现快慢分离, ...

  3. Delphi Stringlist Delimiter如何区分TAB和空格

    var st: TStrings; begin st := TStringList.Create; st.StrictDelimiter := True;//这个多少人用过? st.Delimiter ...

  4. JavaUtil_09_email_使用 commons-email 发送邮件

    二.参考资料 1.[commons]邮件发送工具——commons-email

  5. L105

    A pill could soon radio signals from inside your gut to help doctors diagnose diseases from ulcers t ...

  6. DFS的简单应用(zoj2110,poj1562)

    zoj2110 简单的dfs应用,注意have数组的处理 #include<iostream> #include<cstdio> #include<cstdlib> ...

  7. Gym - 100570C: Subrect Query (巧妙的单调队列)

    De Prezer loves rectangles.He has a n × m rectangle which there is a number in each of its cells. We ...

  8. 标准模板库(STL)学习指南之set集合

    set是关联容器.其键值就是实值,实值就是键值,不可以有重复,所以我们不能通过set的迭代器来改变set的元素的值,set拥有和list相同的特性:当对他进行插入和删除操作的时候,操作之前的迭代器依然 ...

  9. centos 6 rsync+inotify 实时同步

    主机名.ip: server 172.31.82.184 client  172.31.82.185 需求: 1.server端 ”/data/server“ 做为client端 “/data/cli ...

  10. HDOJ1213(并查集)

    set容器中的值互异,非常好用. 水题,直接贴代码了 #include<iostream> #include<cstdio> #include<set> using ...