Codeforces Round #246 (Div. 2)(B)数学
来源:互联网 发布:网络安全法的特点 编辑:程序博客网 时间:2024/06/08 21:38
题意:有n个球队相互比赛(要比n*(n-1)次),他们有主场服装和客场服装,颜色不相同。穿戴规则如下:
如果是主场,穿主场的服装
如果是客场,分2种情况
如果客场时的客场服装颜色与对方的主场衣服颜色相同,那么就穿自己的主场衣服。否则就穿直接穿客场服装。
题解:首先我们要知道每支队伍都要穿2*(n-1)次衣服,先使用数字统计主场,客场各自颜色数量。
然后就是一支队伍,最少要穿n-1次主场服装。然后要穿与自己客场相同颜色的主场次数次主场服装(很绕口,看不懂直接看代码吧。。。),然后用2*(n-1)减去主场的次数,剩下来就是客场的次数了。
#include <set> #include <map> #include <list> #include <cmath> #include <queue> #include <vector> #include <cstdio> #include <string> #include <cstring> #include <iomanip> #include <iostream> #include <sstream> #include <algorithm> #define LL long long using namespace std; #define N 200000 #define inf 0x3f3f3f3fLL x[N],y[N];struct point{LL xx,yy;}ans[N];LL n,xi[N],yi[N];int main() { #ifdef CDZSC freopen("i.txt","r",stdin); #endif while(~scanf("%lld",&n)){memset(x,0,sizeof(x));memset(y,0,sizeof(y));for(int i=0;i<n;i++){scanf("%lld%lld",&xi[i],&yi[i]);x[xi[i]]++;y[yi[i]]++;}for(int i=0;i<n;i++){ans[i].xx=x[yi[i]]+n-1;ans[i].yy=2*(n-1)-ans[i].xx;}for(int i=0;i<n;i++){printf("%lld %lld\n",ans[i].xx,ans[i].yy);}}return 0;}
0 0
- Codeforces Round #246 (Div. 2)(B)数学
- Codeforces Round #282 (Div. 2) B.(数学)
- Codeforces Round #340 (Div. 2)(B) 数学
- Codeforces Round #341 (Div. 2)(B)数学
- Codeforces Round #353 (Div. 2)-B. Restoring Painting(数学)
- Codeforces Round #196 (Div. 2) / 337B Routine Problem(数学)
- Codeforces Round #224 (Div. 2) B 数学推理
- Codeforces Round #319 (Div. 2)B. Modulo Sum(数学,DP)
- Codeforces Round #384 (Div. 2)(数学)
- Codeforces Round #246 (Div. 2)(C)数学,思维
- Codeforces Round #256 (Div. 2)(B)
- Codeforces Round #350 (Div. 2)(B)
- Codeforces Round #379 (Div. 2)B
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(数学规律)
- Codeforces Round #340 (Div. 2)-B. Chocolate(组合数学的乘法计数)
- Codeforces Round #278 (Div. 2) B. Candy Boxes (模拟,数学)
- Codeforces Round #260 (Div. 2) B. Fedya and Maths (数学规律)
- Codeforces Round #364 (Div. 2) B Cells Not Under Attack(数学)
- 1、字符串的操作
- debian 发行代号
- ssh远程登陆命令
- WPF数据绑定学习
- 全面复习之SQL(8)-oracle存储过程
- Codeforces Round #246 (Div. 2)(B)数学
- unable to start the virtual device the virtual device got no ip address一个解决方法
- 使用MongoDB Shell
- PropertyAnimation属性动画资源 ArgbEvaluator使用
- 自学成才篇:再谈字节流的Read方法
- poj 3411 Paid Roads(DFS)
- 并行计算之路<1>——Hello, CUDA.
- lua三目运算符问题
- 四大组件基本使用实践总结