codeforce 621B Wet Shark and Bishops
对角线 x1+y1=x2+y2 或者x1-y1=x2-y2
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a))
const int maxn=; int main()
{
int n;
int x,y;
int a[maxn];
int b[maxn];
scanf("%d",&n);
clc(a,);
clc(b,);
for(int i=;i<n;i++)
{
scanf("%d%d",&x,&y);
a[x+y]++;
b[x-y+]++;
}
ll sum=;
for(int i=;i<=;i++)
{
if(a[i]%)
sum+=(a[i]-)/*a[i];
else
sum+=a[i]/*(a[i]-);
}
for(int i=-+;i<=+;i++)
{
if(b[i]%)
sum+=(b[i]-)/*b[i];
else
sum+=b[i]/*(b[i]-);
}
printf("%I64d\n",sum);
return ;
}
codeforce 621B Wet Shark and Bishops的更多相关文章
- CodeForces 621B Wet Shark and Bishops
记录一下每个对角线上有几个,然后就可以算了 #include<cstdio> #include<cstring> #include<cmath> #include& ...
- B. Wet Shark and Bishops(思维)
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces 612B. Wet Shark and Bishops 模拟
B. Wet Shark and Bishops time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- Wet Shark and Bishops(思维)
Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are nu ...
- 【CodeForces 621B】Wet Shark and Bishops
题 题意 1000*1000的格子里,给你n≤200 000个点的坐标,求有多少对在一个对角线上. 分析 如果求每个点有几个共对角线的点,会超时. 考虑到对角线总共就主对角线1999条+副对角线199 ...
- Codeforces Round #341 Div.2 B. Wet Shark and Bishops
题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数 由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y 然后每个数组中扫描重复数字k ans加上kC ...
- codeforce 621C Wet Shark and Flowers
题意:输入个n和质数p,n个区间,每个区间可以等概率的任选一个数,如果选的这个区间和它下个区间选的数的积是p的倍数的话(n的下个是1),就挣2000,问挣的期望 思路:整体的期望可以分成每对之间的期望 ...
- codeforce 621A Wet Shark and Odd and Even
水 最大偶数和 #include<iostream> #include<string> #include<algorithm> #include<cstdli ...
- Chocolate&&木块拼接&&Cards&& Wet Shark and Bishops
B. Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- slqplus 帮助手册
1.查看sqlplus的帮助是否可用,必须登录了才可用. D:\app\product\\db_1\sqlplus\admin\help>sqlplus /nolog SQL :: Copyri ...
- 创建第一个UI
创建一个2D UI 制作UI时,首先要创建UI的"根".在Unity顶部NGUI菜单中选择Create,然后选择2D UI. 创建完成后,在Scene窗口中,NGUI自动生成了一个 ...
- Centos安装gnome主菜单编辑器无
首选项---主菜单-- 即是alacarte.. centos ===安装 alacarte.noarch 0:0.12.4-1.el6 即可.
- HDU4528+BFS
/* bfs+标记状态 如何记录状态是关键!! */ #include<stdio.h> #include<string.h> #include<stdlib.h> ...
- IIS虚拟目录实现与文件服务器网络驱动器映射共享
这篇文章转载别人,想原创作者致敬! 我本人也遇到同样的问题,故转载记录. 本文重点描述如何使用IIS访问共享资源来架设站点或执行 ASP.Net 等脚本. 通常情况下,拥有多台服务器的朋友在使用IIS ...
- 使用 DiskMaker X 轻松制作 Yosemite 安装 U 盘(引)
使用 DiskMaker X 轻松制作 Yosemite 安装 U 盘 由于帮人在MacBook上装Windows, 用pe格式化了一下分出来的Windows分区, 搞得Mac系统也瘫掉了, 无奈之下 ...
- VC常用数据类型使用转换
我们先定义一些常见类型变量借以说明 int i = 100; long l = 2001; float f=300.2; double d=12345.119; char username[]=&qu ...
- 判断微信内置浏览器的UserAgent
要区分用户是通过"微信内置浏览器"还是"原生浏览器"打开的WebApp, 可以通过navigator.userAgent来进行判断. 以下是对各种平台上微信内置 ...
- Ember.js demo1
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1 ...
- APP-PAY-06153 When Trying To Open Organization Definition Form (文档 ID 1323165.1)
In this Document Symptoms Cause Solution Applies to: Oracle Inventory Management - Version 11.5.10.2 ...