题意略。

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

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. Xshell为什么连不上虚拟机

  2. kafka集群跨双网段及多网段通信问题解决

    一.问题场景: 实际生产环境总存在很多kafka集群跨网段的问题.kafka集群可能存在多个网卡,对应多个网段.不同网段之间需要同时与集群通信,即跨网段生产消费问题. 二.解决方法:自定义listen ...

  3. 【iOS】UILabel 常用属性设置

    UILabel 的一些常用属性,示例代码如下: // 字体大小 label.font = [UIFont systemFontOfSize:14.0]; label.font = [UIFont fo ...

  4. 【Android】Mac Android adb 配置

    打开终端,输入下面命令: touch .bash_profile open -e .bash_profile 即新建 “.bash_profile” 文件,并会弹出 “.bash_profile” 文 ...

  5. Mac Android 配置环境变量

    进入终端,输入以下命令: cd ~ touch .bash_profile //没有该文件的话新建一个 vi .bash_profile //vim 形式打开 输入内容jdk变量配置内容: expor ...

  6. Netty+WebSocket 获取火币交易所数据项目

    Netty+WebSocket 获取火币交易所时时数据项目 先附上项目项目GitHub地址 spring-boot-netty-websocket-huobi 项目简介 本项目使用 SpringBoo ...

  7. 自定义SWT控件二之自定义多选下拉框

    2.自定义下拉多选框 package com.view.control.select; import java.util.ArrayList; import java.util.HashMap; im ...

  8. 调试过程中发现按f5无法走进jdk源码

    debug 模式 ,在fis=new FileInputStream(file); 行打断点 调试过程中发现按f5无法走进jdk源码 package com.lzl.spring.test; impo ...

  9. maven 下载 安装 环境配置

    电脑系统:win10  64位   idea 2019    Java 1.8 1.链接地址,我一般都找官网 http://maven.apache.org/download.cgi 截图:注意mav ...

  10. 什么是https?http升级为https需要什么?

    一.什么是https? https是一种加密传输协议,网站使用https后可以避免敏感信息被第三方获取.https加密协议=SSL / TLS+http协议,也就是说,在传统的http协议上加上SSL ...