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. idea反编译失败 /* compiled code */的解决方法

    最近在研究源码,但是我的idea有点奇怪,有的文件可以反编译,但有的文件反编译后方法内容是 /* compiled code */,查了下说是反编译失败了,都说是插件的原因. 然后我看了下idea的插 ...

  2. 多线程02.继承Thread类

    package chapter2; /** * 1.使用static虽然完成了当前的功能. * 但是static的生命周期比较长,需要在所有线程执行完成后才会结束. * 还有号没有按照顺序进行打印 * ...

  3. Python+selenium之多窗口,句柄

  4. Ubuntu怎么修改DNS

    有时候会出现配置好网络之后,可以ping通网关却ping不通www.baidu.com orangepi@orangepi3:~$ ping 192.168.1.1 PING 192.168.1.1 ...

  5. CF 585 E Present for Vitalik the Philatelist

    CF 585 E Present for Vitalik the Philatelist 我们假设 $ f(x) $ 表示与 $ x $ 互质的数的个数,$ s(x) $ 为 gcd 为 $ x $ ...

  6. Codeforces 582D - Number of Binominal Coefficients(Kummer 定理+数位 dp)

    Codeforces 题目传送门 & 洛谷题目传送门 一道数论与数位 dp 结合的神题 %%% 首先在做这道题之前你需要知道一个定理:对于质数 \(p\) 及 \(n,k\),最大的满足 \( ...

  7. 毕业设计压力测试——jmeter

    ------------恢复内容开始------------ JMeter是一款纯java编写负载功能测试和性能测试开源工具软件.相比Loadrunner而言,JMeter小巧轻便且免费,逐渐成为了主 ...

  8. 分布式事务(3)---强一致性分布式事务Atomikos实战

    分布式事务(1)-理论基础 分布式事务(2)---强一致性分布式事务解决方案 分布式事务(4)---最终一致性方案之TCC 前面介绍强一致性分布式解决方案,这里用Atomikos框架写一个实战的dem ...

  9. 【STM32】使用SDIO进行SD卡读写,包含文件管理FatFs(四)-介绍库函数,获取一些SD卡的信息

    其他链接 [STM32]使用SDIO进行SD卡读写,包含文件管理FatFs(一)-初步认识SD卡 [STM32]使用SDIO进行SD卡读写,包含文件管理FatFs(二)-了解SD总线,命令的相关介绍 ...

  10. linux 挂载本地iso

    mount -t iso9660 -o loop /mnt/temp/rhel-server-6.5-i386-dvd.iso /mnt/cdrom -t :设备类型 iso9660是指CD-ROM光 ...