Content

有一个 \(n\times n\) 的矩阵,每个元素都有一个权值。求所有满足其所在纵列所有元素权值和大于其所在横列所有元素权值和的元素个数。

数据范围:\(1\leqslant n\leqslant 30\)。

Solution

直接对于每个元素暴力求出其所在纵列所有元素权值和以及其所在横列所有元素权值和,再进行比较加入计数器。复杂度 \(\mathcal{O}(n^3)\),别说这题 \(30\) 的数据范围了,我看给个 \(n\leqslant 500\) 也不为过。

Code

int n, a[37][37], ans;

int main() {
n = Rint;
F(i, 1, n) F(j, 1, n) a[i][j] = Rint;
F(i, 1, n) F(j, 1, n) {
int sum1 = 0, sum2 = 0;
F(k, 1, n) sum1 += a[k][j];
F(k, 1, n) sum2 += a[i][k];
ans += (sum1 > sum2);
}
return write(ans), 0;
}

CF157A Game Outcome 题解的更多相关文章

  1. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  2. 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 ...

  3. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  4. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  5. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  6. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  7. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  8. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  9. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

随机推荐

  1. nothing to commit, working tree clean

    本地git提交代码,没有发现有什么啥情况. 本地代码提交不上去

  2. spring-整合es

    spring-整合es 导入pom  <?xml version="1.0" encoding="UTF-8"?> <project xmln ...

  3. spring中使用@value注入static静态变量

    @Value("${meeting.private_key}")public static String PRIVATE_KEY;发现没有数据,null 分析 Spring是不能直 ...

  4. Python字符出现次数统计

    1.读取文本文档 红球.txt 2.运行代码 with open('红球.txt', "r", encoding="utf-8")as f: d = {} fo ...

  5. x86汇编反编译到c语言之——(2)if语句

    一. 测试的C语句及编译后的x86汇编代码 int a; int b; int main(void) { int c; if (c) a = 4; else b = 5; return 0; } 1 ...

  6. 解决texlive化学式转换镜像经常偶发性进程堆积导致卡顿问题

    前言 之前在 使用Python定时清理运行超时的pdflatex僵尸进程 博文中我采用python脚本开启定时任务清理pdflatex僵尸进程,线上4u2G的k8s pod部署了3个,pdflatex ...

  7. ISIJ2021 游记

    Day -419 ~ ? - 2020.5.8 ~ ? 咦?ISIJ2021 怎么会扯到 2020 年的事情呢? 好吧这似乎真的是一个长篇大论,事情真的要从那一天开始讲起-- 仍依稀记得 2020 年 ...

  8. Codeforces Round #681 (Div. 1) Solution

    A. Extreme Subtraction 把这个数组差分一下,发现操作一的作用是把 \(d_1\) 的大小分给 \(d_i\),而操作二的作用是把 \(d_i\) 减去任意值,目标是把 \(d\) ...

  9. R语言与医学统计图形-【16】ggplot2几何对象之标签与文本

    ggplot2绘图系统--添加标签与文本.数学表达式.条形图文本.注释 1. 文本与标签添加 geom_label的文本将以标签形式出现,即文本会带有一个背景色. geom_text则是纯文本形式展示 ...

  10. EXCEL excel中运用ctrl+D、ctrl+enter、ctrl+E批量填充数据

    在excel中,利用鼠标拖动可以快速向下或者向右填充序列或者复制单元格.但是利用快捷键也可以实现多种填充方式,本文就为大家介绍一些ctrl系列快捷键的填充,一起来看看吧. 封面tu 一,ctrl+D/ ...