CodeForces 157A Game Outcome
2 seconds
256 megabytes
standard input
standard output
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the
board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares.
To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this
row (including the given square). A square is consideredwinning if the sum of the column numbers is strictly greater than the sum
of the row numbers.
For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24,
sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.
The first line contains an integer n (1 ≤ n ≤ 30).
Each of the following n lines contain n space-separated
integers. The j-th number on the i-th
line represents the number on the square that belongs to the j-th column and the i-th
row on the board. All number on the board are integers from 1 to 100.
Print the single number — the number of the winning squares.
1
1
0
2
1 2
3 4
2
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
6
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
int r[35];
int l[35];
int a[35][35];
int n;
int main()
{
scanf("%d",&n);
memset(r,0,sizeof(r));
memset(l,0,sizeof(l));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
scanf("%d",&a[i][j]); }
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
r[i]+=a[i][j];
l[i]+=a[j][i];
}
}
int num=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(l[j]>r[i])
num++;
}
}
printf("%d\n",num);
return 0;
}
CodeForces 157A Game Outcome的更多相关文章
- CodeForces 451C Predict Outcome of the Game
Predict Outcome of the Game Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &a ...
- codeforces 258div2C Predict Outcome of the Game
题目链接:http://codeforces.com/contest/451/problem/C 解题报告:三个球队之间一共有n场比赛,现在已经进行了k场,不知道每个球队的胜场是多少,如三个球队的胜场 ...
- codeforces 451C. Predict Outcome of the Game 解题报告
题目链接:http://codeforces.com/problemset/problem/451/C 题目意思:有3支球队(假设编号为1.2.3),总共要打 n 场比赛,已知已经错过这n场比赛中的 ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...
- Codeforces Round #258 (Div. 2/C)/Codeforces451C_Predict Outcome of the Game(枚举)
解题报告 http://blog.csdn.net/juncoder/article/details/38102391 题意: n场比赛当中k场是没看过的,对于这k场比赛,a,b,c三队赢的场次的关系 ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- Codeforces Round #379 (Div. 2) A. Anton and Danik 水题
A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play ...
- [codeforces 293]A. Weird Game
[codeforces 293]A. Weird Game 试题描述 Yaroslav, Andrey and Roman can play cubes for hours and hours. Bu ...
随机推荐
- jms、amqp、mqtt区别与联系
消息传递作为基本通信机制已经在全世界成功运用.无论是人与人.机器与人还是机器与机器之间,消息传递一直都是唯一常用的通信方式.在双方(或更多)之间交换消息有两种基本机制. 同步消息传递 异步消息传递 同 ...
- openssl C语言编码实现rsa加密
非原创, 引用自: 1 CC=gcc CPPFLAGS= -I /home/yyx//openssl-1.0.1t/include/ CFLAGS=-Wall -g LIBPATH = -L /usr ...
- 1-wire单总线DS18B20
要想实现单总线通信,每一个挂在总线上的从机必须拥有开路或3态输出.单总线DS18B20的DQ引脚用内部电路实现了开漏输出,其等效电路如下图: 当单片机IO引脚配置为 mcu IO引脚 电流流向 DS1 ...
- 重置linux mysql root密码
2.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/my ...
- 最全面的 Sublime Text 使用指南
最全面的 Sublime Text 使用指南 摘要(Abstract) 本文系统全面的介绍了Sublime Text,旨在成为最优秀的Sublime Text中文教程. 前言(Prologue) ...
- Python学习笔记7:函数对象及函数对象作參数
一.lambda函数 比如: fun1 = lambda x,y: x + y print fun1(3,4) 输出:7 lambda生成一个函数对象.该函数參数为x,y,返回值为x+y.函数对象赋给 ...
- 新标准C++程序设计读书笔记_类和对象
面向对象的程序设计方法 抽象:将某类客观事物共同特点(属性)归纳出来,形成一个数据结构(可以用多个变量描述事物的属性):将这类事物所能进行的行为也归纳出来,形成一个个函数,这些函数可以用来操作数据结构 ...
- 折腾gcc/g++链接时.o文件及库的顺序问题(转)
转自: http://www.cnblogs.com/OCaml/archive/2012/06/18/2554086.html#sec-1-1 折腾gcc/g++链接时.o文件及库的顺序问题 Tab ...
- liunx下安装tomcat7.0.82
1.apache-tomcat-liunx-7.0.82下载地址: http://download.csdn.net/download/yichen01010/10019116 2.下载后解压即可 c ...
- android之ViewPager修改滑动速度
在android中,使用过viewpager的人都清楚,我们如果使用viewpager进行滑动时,如果通过手指滑动来进行的话,可以根据手指滑动的距离来实现,但是如果通过setCurrentItem函数 ...