CF#341-B-Wet Shark and Bishops-水题
来源:互联网 发布:淘宝解冻的金额在哪 编辑:程序博客网 时间:2024/06/05 02:11
http://codeforces.com/contest/621/problem/B
给你一个1000*1000的矩阵,上的n个点,
计算每个对角线上有多少个点,如果一个对角线有n个点,代表有n个牧师,会互相打架,计算打架总数
直接统计每条对角线多少个点,然后 ....n个人,有n*(n-1)/2场架,GG
//注意主对角线要+n,否则下标为负数
#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <iostream>#include <queue>#include <map>#include <set>#include <vector>#include<stack>using namespace std; __int64 L[2005*2];//副对角线元素之和 __int64 R[2005*2]; //主对角线元素之和 int main(){ int n;int i,x,y;scanf("%d",&n); for (i=1;i<=n;i++){ scanf("%d %d",&x,&y); L[x+y]++; R[x-y+1000]++; //注意}__int64 sum=0;for (i=0;i<=2000;i++){if (L[i]) sum+= L[i]*(L[i]-1)/2;if (R[i]) sum+= R[i]*(R[i]-1)/2;}printf("%I64d\n",sum);return 0;}
0 0
- CF#341-B-Wet Shark and Bishops-水题
- B. Wet Shark and Bishops
- Codeforces Round #341 (Div. 2) B. Wet Shark and Bishops
- Codeforces Round #341 (Div. 2) --B. Wet Shark and Bishops
- Codeforces Round #341 (Div. 2) B. Wet Shark and Bishops
- Codeforces Round #341 (Div. 2)B - Wet Shark and Bishops
- Codeforces #341div2 B.Wet Shark and Bishops(暴力)
- Codeforces Round #341 (Div. 2)B. Wet Shark and Bishops
- codeforce 621B Wet Shark and Bishops
- codeforce 621 B. Wet Shark and Bishops
- CodeForces 621 B Wet Shark and Bishops
- 【codeforces】#621B-Wet Shark and Bishops
- 【CodeForces】[621B]Wet Shark and Bishops
- 【CodeForces】#621B - Wet Shark and Bishops
- CodeForces 621B Wet Shark and Bishops
- CodeForces 621B Wet Shark and Bishops
- Codeforces 621B Wet Shark and Bishops
- Wet Shark and Bishops
- Codeforces 621 D Rat Kwesh and Cheese
- [android]_[handler的简单使用]
- 业界资讯:swift的API正在转变
- 集合 TreeSet HashMap
- 整数划分问题经典解法(有用)
- CF#341-B-Wet Shark and Bishops-水题
- 补充:this的应用
- 【杭电】[2024]C语言合法标识符
- 记录Android-Studio遇到的各种坑
- OPENSTACK 虚拟机镜像制作指南 示例:Ubuntu 镜像
- cf#341-C. Wet Shark and Flowers-数学-概率计算
- 自定义View笔记一
- [android]_[Async异步任务使用]
- 重建二叉树