题意略。

思路:我们来写一下公式:

P1:(x1 + t * Vx1,y1 + t * Vy1)                P2:(x2 + t * Vx2,y2 + t * Vy2)

x1 + t * Vx1 = x2 + t * Vx2

y1 + t * Vy1 = y2 + t * Vy2

a(x1 - x2) = t * (Vy2 - Vy1)

x1 - x2 = t * (Vx2 - Vx1)

a * (Vx2 - Vx1) = Vy2 - Vy1

说明满足a * Vx2 - Vy2 = a * Vx1 - Vy1这个式子的就可以相交。

这里要特殊考虑一下平行情况,我们要从所有贡献中减去平行的不合法情况,才能得到最终答案。注意,几个静止的点也是平行的。

详见代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL; LL n,a,b,vx,vy;
map<LL,LL> mp;
map<pair<LL,LL>,LL> mp1; int main(){
scanf("%lld%lld%lld",&n,&a,&b);
LL x;
for(int i = ;i < n;++i){
scanf("%lld%lld%lld",&x,&vx,&vy);
LL s = a * vx - vy;
++mp[s];
mp1[make_pair(vx,vy)]++;
}
map<LL,LL>::iterator it;
LL sum = ;
for(it = mp.begin();it != mp.end();++it){
LL temp = it->second;
LL contribute = temp * (temp - );
sum += contribute;
}
map<pair<LL,LL>,LL>::iterator it1;
for(it1 = mp1.begin();it1 != mp1.end();++it1){
LL temp = it1->second;
sum -= temp * (temp - );
}
printf("%lld\n",sum);
return ;
}

Codeforces 975D的更多相关文章

  1. Codeforces 975D. Ghosts

    Description 给出一条直线 \(a*x+b\) 上的 \(n\) 个点,每一个点有一个速度 \((v_x,v_y)\),求 \(T=[-oo,oo]\) 相交的次数乘以 \(2\) 题面 S ...

  2. Codeforces Round #478 Div2 975A 975B 975C 975D

    A. Aramic script 题目大意:   对于每个单词,定义一种集合,这个集合包含且仅包含单词中出现的字母.给你一堆单词,问有多少种这种集合. 题解:   状压,插入set,取size #in ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. python模块导入-软件开发目录规范-01

    模块 模块的基本概念 模块: # 一系列功能的结合体 模块的三种来源 """ 模块的三种来源 1.python解释器内置的模块(os.sys....) 2.第三方的别人写 ...

  2. FAIRR

    FAIRR 在进行一项工作时需要注意学习.应用和改进已有信息和成果,可参考FAIRR原则: Find existing info and result, Add to and Improve it, ...

  3. 程序员的长安十二时辰:Java实现从Google oauth2.0认证调用谷歌内部api

    最近公司在做一个app购买的功能,主要思路就是客户在app上购买套餐以后,Google自动推送消息到Java后端,然后Java后端通过订单的token获取订单信息,保存到数据库. Java后端要获取订 ...

  4. dubbo同步调用、异步调用和是否返回结果源码分析和实例

    0. dubbo同步调用.异步调用和是否返回结果配置 (1)dubbo默认为同步调用,并且有返回结果. (2)dubbo异步调用配置,设置 async="true",异步调用可以提 ...

  5. 有不少朋友问我Halcon和Opencv的区别?

    Halcon:机器视觉行业里知名的商业视觉库,非开源的,在国内市场份额处于第一,其提供了1500个多个API算子供开发人员使用,有些编程基础的都可以轻松的入门,其调试也是很方便的,断点单步运行,图像变 ...

  6. IIS网站服务器性能优化攻略

    Windows Server自带的互联网信息服务器(Internet Information Server,IIS)是架设网站服务器的常用工具,它是一个既简单而又麻烦的东西,新手都可以使用IIS架设一 ...

  7. 日常用shell命令

    递归更改文件夹权限:chmod -R 767 文件名 mac启动apache sudo apachectl start/restart mac停止apache sudo apachectl stop ...

  8. 【MySQL】Unknown column 'column_name' in 'field list'

    使用 INSERT INTO - SELECT FROM - ON DUPLICATE KEY UPDATE 时遇到了这个问题,百思不得其解

  9. 中国地区表SQL语句

    /* Navicat MySQL Data Transfer Source Server : 本机 Source Server Version : 50553 Source Host : localh ...

  10. mysql limit分页查询效率比拼

    1.直接使用数据库提供的SQL语句 limit M ,N SELECT * from message limit 0 , 10 ; -- 0.044 SELECT * from message lim ...