Codeforces Round #341 Div.2 B. Wet Shark and Bishops
题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数
由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y
然后每个数组中扫描重复数字k ans加上kC2就行了
wa了两发的原因是没考虑到如果整个数组都是重复的 那要最后额外加一次
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#define INF 0x3f3f3f3f
#define mem(str,x) memset(str,(x),sizeof(str))
#define STOP puts("Pause");
using namespace std;
typedef long long LL; int n, node[], node2[];
LL ans; int main()
{
ans = ;
scanf("%d", &n);
for(int i = ; i <= n; i++){
int x, y;
scanf("%d%d", &x, &y);
node[i] = x - y;
node2[i] = x + y;
}
sort(node + , node + + n);
sort(node2 + , node2 + + n);
LL count = ;
for(int i = ; i <= n; i++){
if(node[i] == node[i-]) count++;
else{
ans += (count * (count - ) / );
count = ;
}
}
ans += (count * (count - ) / );
count = ;
for(int i = ; i <= n; i++){
if(node2[i] == node2[i-]) count++;
else{
ans += (count * (count - ) / );
count = ;
}
}
ans += (count * (count - ) / );
printf("%I64d\n", ans);
return ;
}
Codeforces Round #341 Div.2 B. Wet Shark and Bishops的更多相关文章
- Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks dp+矩阵加速
题目链接: http://codeforces.com/problemset/problem/621/E E. Wet Shark and Blocks time limit per test2 se ...
- Codeforces Round #341 Div.2 C. Wet Shark and Flowers
题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里 ...
- Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even
题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include < ...
- Codeforces Round #341 (Div. 2) E - Wet Shark and Blocks
题目大意:有m (m<=1e9) 个相同的块,每个块里边有n个数,每个数的范围是1-9,从每个块里边取出来一个数组成一个数,让你求组成的方案中 被x取模后,值为k的方案数.(1<=k< ...
- Codeforces Round #341 (Div. 2)
在家都变的懒惰了,好久没写题解了,补补CF 模拟 A - Wet Shark and Odd and Even #include <bits/stdc++.h> typedef long ...
- Codeforces Round #341 (Div. 2) ABCDE
http://www.cnblogs.com/wenruo/p/5176375.html A. Wet Shark and Odd and Even 题意:输入n个数,选择其中任意个数,使和最大且为奇 ...
- Codeforces Round #341 (Div. 2)B
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #341 (Div. 2) D. Rat Kwesh and Cheese 数学
D. Rat Kwesh and Cheese 题目连接: http://www.codeforces.com/contest/621/problem/D Description Wet Shark ...
- Codeforces Round #341 (Div. 2)A
A. Wet Shark and Odd and Even time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
随机推荐
- iOS 指定圆角个数
需要实现的效果很明确,只要左上和右上两个地方圆角,以前都是通过layer 直接设置四个角都变成圆角,然后我就开始了强大的搜索功能 然后我就获得了我想要的东西 技术链接:http://www.xuebu ...
- Theoretical comparison between the Gini Index and Information Gain criteria
Knowledge Discovery in Databases (KDD) is an active and important research area with the promise for ...
- WPF环境下多点触屏开发的一些经验(转)
本系列将介绍Multi-Touch(MT)多点触控技术的相关内容,使开发人员了解如何在Windows 平台中开发出具有MT 功能的应用程序.众所周知Windows 7 操作系统自身已经支持具有MT 功 ...
- Java反射机制专题
·Java Reflection Reflection(反射)是被视为动态语言的关键,反射机制允许程序在执行期借助于Reflection API取得任何类的内部信息,并能直接操作任意对象的内部属性及方 ...
- MySQL数据库7 - 汇总和分组数据
一 汇总和分组数据 查询语句 ---> 结果集(多条数据) ---> 聚合函数 ----> 单行记录 1.常用的聚合函数: sum() 数字 ...
- IOS managerTime
1. NSString ->NSdate NSString *birthday = self.btnBirthday.titleLabel.text; NSDateFormatter *dat ...
- Linux中的find(-atime、-ctime、-mtime)指令分析
本篇主要对find -atime(-ctime..mtime)指令的用法.参数.运行情况进行分析 用法: find . {-atime/-ctime/-mtime/-amin/-cmin/-mmin} ...
- Unity jounal 2016-3-3
1. Project organization: 2.prefab Important part of the project, which seperate and organize the scr ...
- Record:Handle onClick for our custom LinearLayout for Gallery-like HorizontalScrollView
Handle onClick for our custom LinearLayout for Gallery-like HorizontalScrollView The post "Im ...
- asp.net fileupload上传大文件时提示404.13错误
IIS 7 默认文件上传大小时30M 要突破这个限制,需要做如下操作: 1. 修改IIS的applicationhost.config 打开 %windir%\system32\inetsrv ...