#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. js 跨域复习 window.name | window.domain | iframe | Jsonp

    引起跨域的原因: 浏览器的同源策略,但是当你要发送请求的时候,出于安全性问题,浏览器有严格的要求,必须协议,域名,端口都相同,这个就是同源策略. 影响:a通过js脚本向b发送ajax请求,不同源就会报 ...

  2. 给手机发验证码 综合使用 (忘记密码处理 php发验证码 重置用户密码)

    前台页面 提取手机号调用 jQuery的ajax,到发送验证码 [php] view plain copy <title>找回密码 - 2015年xxx报名系统</title> ...

  3. php如何判断电脑访问还是手机访问?

    手机上网用户数量越来越大,如今各网站都推出了手机网站,电脑用户访问时直接访问电脑版网页,当用户通过手机访问网站时则跳自动跳转到手机版网页,下面给大家分享一段php中判断电脑访问还是手机访问的代码: & ...

  4. queryRuner如何获得bean对象,当这个bean对象中包含其他对象的时候

    我们知道我们可以使用dbutil的QueryRunner下的query方法使用BeanHandler得到bean对象 但是,当我们在一个表和另一个表关联的时候,往往喜欢将另一个表的关联字段变成另一个b ...

  5. Java丨验证码图片去除干扰像素,方便验证码的识别

    1.先来看看效果: 原图 除去干扰像素后 2.解析代码: 1).读取文件夹里面的图片 String fileName = "picture"; BufferedImage img ...

  6. 素数环:NYOJ--488--dfs||hdu-1016-Prime Ring Problem

    /* Name: NYOJ--488--素数环 Author: shen_渊 Date: 15/04/17 15:30 Description: DFS,素数打个表,37以内就够用了 */ #incl ...

  7. L105

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

  8. cudnn 卷积例子

    运行环境:linux cuda cudnn cudnn API:https://docs.nvidia.com/deeplearning/sdk/cudnn-developer-guide/index ...

  9. 3.3 CCSprite 精灵详解

    3.3.1 创建精灵常用的 4 种方式 (当然还有其他方式,只不过 这四种比较常用) //创建精灵常用的 4 种方式 CCSprite* spr1 = CCSprite::create(const c ...

  10. 将tomcat7解压版注册为windows系统服务

    一.修改service.bat文件(...tomcat7\bin\service.bat) 该文件中共修改两处即可 ①:在文件的开头加入以下设置,分别是java的安装路径.Tomcat的安装路径及服务 ...