#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. GridView行中按钮的使用

    转载自:http://blog.csdn.net/hongdi/article/details/6455947 GridView行中按钮的使用 在web项目的过程中,特别是开发ASP.NET应用程序, ...

  2. 分布式系统的Raft算法——在失联阶段这个老Leader的任何更新都不能算commit,都回滚,接受新的Leader的新的更新 意味着还是可能丢数据!!!

    过去, Paxos一直是分布式协议的标准,但是Paxos难于理解,更难以实现,Google的分布式锁系统Chubby作为Paxos实现曾经遭遇到很多坑. 来自Stanford的新的分布式协议研究称为R ...

  3. Spring JdbcTemplate详解(转)

    原文地址:http://www.cnblogs.com/caoyc/p/5630622.html   尊重原创,请访问原文地址 JdbcTemplate简介 Spring对数据库的操作在jdbc上面做 ...

  4. Oracle学习笔记_01_SQL初步

    1.分类 SQL语句分为以下三种类型: DML: Data Manipulation Language        数据操纵语言       DDL: Data Definition Languag ...

  5. 动态规划 最长回文子串 leetcode5

    public static String longestPalindrome(String s) { if(null==s||s.length()==0) return s; int n=s.leng ...

  6. 如何用Mendeley引用目标期刊要求的参考文献格式

    如果我们要向目标的杂志期刊投稿,则需要采用该期刊的参考文献格式.我用的mendeley管理文献,不收费且使用方便.那么,我们如何用mendeley引用目标期刊的参考文献呢?以Applied energ ...

  7. C#中怎么解析JSON数据,并获取到其中的值?

    [1]首先我们根据创建一个json字符转 string json = @"[{'phantom':true,'id':'20130717001','data':{'MID':1019,'Na ...

  8. ACM学习历程—UESTC 1226 Huatuo's Medicine(数学)(2015CCPC L)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1226 题目就是构造一个对称的串,除了中间的那个只有1个,其余的两边都是对称的两个,自然答案就是2*n-1. ...

  9. Swift中的参数内部名称和外部名称

    1.什么是参数的内部名称和外部名称? struct Color { let red, green, blue: Double init(red redColor: Double,green green ...

  10. 洛谷【P2115】[USACO14MAR]破坏Sabotage

    我对二分的理解:https://www.cnblogs.com/AKMer/p/9737477.html 题目传送门:https://www.luogu.org/problemnew/show/P21 ...