Problem E: 矩阵鞍点
AC代码
#include<stdio.h>
int main()
{
int a[][];
int b[];
int i,j,t,n;
while(scanf("%d",&n)!=EOF)
{
int flag = ;//用于标示数组b中是否存在不是-1的元素
for(i=;i<n;i++)
for(j=;j<n;j++)
scanf("%d",&a[i][j]); //找出每一行中最大的元素,并把列号存在数组b中
for(i=;i<n;i++)
{
//默认每一行第一个元素为最大值
b[i] = a[i][];
//引入一个循环变量t用来记录最大值的列号
t = ;
//把最大值的数值暂时存在b中,把最大值的列号暂时存在t中
for(j=;j<n;j++)
{
if(b[i]<a[i][j])
{
b[i] = a[i][j];
t = j;
}
}
//如果一行中有两个相同的最大值,t等于-1
for(j=;j<n;j++)
{
if(b[i]==a[i][j]&&j!=t)
{
t = -;
}
}
//把最大值的列号存在b中
b[i] = t;
} for(i=;i<n;i++)
{
if(b[i]!=-)
{
for(j=;j<n;j++)
{
if(a[i][b[i]]>a[j][b[i]])
{
b[i] = -;
}
else if(a[i][b[i]]==a[j][b[i]]&&i!=j)
{
b[i] = -;
}
}
}
}
for(i=;i<n;i++)
{
if(b[i]!=-)
{
flag = ;
printf("%d %d\n",i,b[i]);
}
}
if(flag==)
{
printf("NO\n");
}
}
return ;
}
AC失败,但输出好像并没有问题
#include<stdio.h>
int main()
{
int n,a[][],i,j;
while(scanf("%d",&n)!=EOF)
{
int flag=,x=,y=,x1=;
for(i=;i<n;i++)
for(j=;j<n;j++)
scanf("%d",&a[i][j]);
for(i=;i<n;i++)
{
for(j=;j<n;j++)
{
if(a[i][j]>a[x][y])
y=j;
}
for(int t=,y=j;t<n;t++)
{
if(a[t][j]<a[x1][j])
x1=t;
}
}
if(x1==x)
{
printf("%d %d\n",x1,y);
flag;
}
else
{
printf("NO\n");
flag=;
}
}
return ;
}
Problem E: 矩阵鞍点的更多相关文章
- HDU1757-A Simple Math Problem,矩阵快速幂,构造矩阵水过
A Simple Math Problem 一个矩阵快速幂水题,关键在于如何构造矩阵.做过一些很裸的矩阵快速幂,比如斐波那契的变形,这个题就类似那种构造.比赛的时候手残把矩阵相乘的一个j写成了i,调试 ...
- hdu 1757 A Simple Math Problem (乘法矩阵)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU----(4291)A Short problem(快速矩阵幂)
A Short problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 1757 A Simple Math Problem(矩阵快速幂乘法)
Problem Description Lele now is thinking about a simple function f(x). If x < f(x) = x. If x > ...
- hdu 4291 A Short problem(矩阵+取模循环节)
A Short problem Time Limit: 2000/1000 MS (J ...
- HDU-1757--A Simple Math Problem(矩阵乘法)
Problem Description Lele now is thinking about a simple function f(x).If x < 10 f(x) = x.If x > ...
- HDU 4291 A Short problem(矩阵+循环节)
A Short problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- A Simple Math Problem(矩阵快速幂)(寒假闭关第一题,有点曲折啊)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU1757:A Simple Math Problem(矩阵快速幂)
http://acm.hdu.edu.cn/showproblem.php?pid=1757 Problem Description Lele now is thinking about a simp ...
随机推荐
- 打开Android系统安装APK的页面
//使用隐式意图开启安装APK的Activity Intent intent = new Intent("android.intent.action.VIEW"); intent. ...
- python进行机器学习(一)之数据预处理
一.加载数据 houseprice=pd.read_csv('../input/train.csv') #加载后放入dataframe里 all_data=pd.read_csv('a.csv', h ...
- python实战===短信验证码的小项目
项目地址 https://www.shiyanlou.com/courses/609/labs/2007/document flask的中文文档 http://docs.jinkan.org/docs ...
- Makefile系列之一 : 书写规则
1. 规则 target : prerequisites command 2. example excute 为最终生成的可执行文件. 可以通过命令 make clean来删除所有编译时产生的中间文 ...
- java实现数据库分页
/*** * 工具类 * @param pageIndex //页码 * @param pageSize//每页数据的条数 * @param rowCount//总的数据条数 * @return */ ...
- 初学jmeter
jmeter安装的前提需要有jdk环境,下载安装好jdk环境后记得要设置好环境变量. 配置环境变量:右击“我的电脑”-->"高级"-->"环境变量" ...
- pdf2htmlEX安装和配置
1.下载 安装的依赖: sudo yum install cmake gcc gnu-getopt java-1.8.0-openjdk libpng-devel fontforge-devel ca ...
- python 结束练习
1.文件操作有哪些模式?请简述各模式的作用 r 只读模式 r+ 读写 rb w 只写模式 w+ 写读 wb x 只写模式 x+ 写读 xb a 追加模式 a+ 写读 ab 2.s = '**hello ...
- Codeforces 877C Slava and tanks(思维)
题目链接:http://codeforces.com/problemset 题目大意:有n个格子,某些格子里可能有一个或多个坦克,但不知道具体位置,每个坦克被轰炸一次就会移动到相邻的格子里(第1个格子 ...
- MySQL的七种join
转载 原文地址 建表 在这里我们先建立两张有外键关联的两张表: CREATE DATABASE db0206; USE db0206; CREATE TABLE `db0206`.`tbl_dept` ...