【CodeForces】[621B]Wet Shark and Bishops
2016-05-29 23:19
585 查看
刚开始认为是对角线
然后发现只要是斜率为1或-1的线的都可以互相攻击
所以可以用数组记录截距来统计在同一直线上的个数
#include<stdio.h> #include<string.h> int a[2020],b[2020]; int main() { int n; while(scanf("%d",&n)!=EOF) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=0; i<n; i++) { int x,y; scanf("%d %d",&x,&y); if(x>y) a[1000+x-y]++; else a[y-x]++; b[x+y]++; } int res=0; for(int i=0; i<2020; i++) { if(a[i]) { res+=(a[i]-1)*a[i]/2; } if(b[i]) { res+=(b[i]-1)*b[i]/2; } } printf("%d\n",res); } return 0; }
题目地址:[621B]Wet Shark and Bishops
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B