博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu4708 Rotation Lock Puzzle
阅读量:6414 次
发布时间:2019-06-23

本文共 2033 字,大约阅读时间需要 6 分钟。

Rotation Lock Puzzle

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 654 Accepted Submission(s): 190

Problem Description
Alice was felling into a cave. She found a strange door with a number square matrix. These numbers can be rotated around the center clockwise or counterclockwise. A fairy came and told her how to solve this puzzle lock: “When the sum of main diagonal and anti-diagonal is maximum, the door is open.”.
Here, main diagonal is the diagonal runs from the top left corner to the bottom right corner, and anti-diagonal runs from the top right to the bottom left corner. The size of square matrix is always odd.
This sample is a square matrix with 5*5. The numbers with vertical shadow can be rotated around center ‘3’, the numbers with horizontal shadow is another queue. Alice found that if she rotated vertical shadow number with one step, the sum of two diagonals is maximum value of 72 (the center number is counted only once).
 

 

Input
Multi cases is included in the input file. The first line of each case is the size of matrix n, n is a odd number and 3<=n<=9.There are n lines followed, each line contain n integers. It is end of input when n is 0 .
 

 

Output
For each test case, output the maximum sum of two diagonals and minimum steps to reach this target in one line.
 

 

Sample Input
5 9 3 2 5 9 7 4 7 5 4 6 9 3 9 3 5 2 8 7 2 9 9 4 1 9 0
 

 

Sample Output
72 1
 

 

Source
 

 

Recommend
liuyiding
很简单的模拟!
 
#include 
#include
#include
#include
using namespace std;int map[12][12];int main(){ int i,j,n,maxx,maxstep,anss,ans; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i
maxx) { maxx=temp; maxstep=min(a,i2-1-a); } else if(temp==maxx) { maxstep=min(maxstep,min(a,i2-1-a)); } } ans+=maxx; anss+=maxstep; } printf("%d %d\n",ans,anss); } return 0;}

| | |

 

转载地址:http://rsdra.baihongyu.com/

你可能感兴趣的文章
CentOS 7 命令行如何连接无线网络
查看>>
Ubuntu 12.04上享用新版本Linux的功能
查看>>
logstash + grok 正则语法
查看>>
Zimbra开源版(v8.6)安装说明
查看>>
Android性能优化之TraceView和Lint使用详解
查看>>
linux centos7.2 安装mysq,nginx,php
查看>>
myrocks之事务处理
查看>>
基于pgrouting的路径规划之一
查看>>
LBS核心技术解析
查看>>
Fible Channel over Convergence Enhanced Ethernet talk about
查看>>
讨论:今日头条适配方案使用中出现的问题
查看>>
CSS3 3D翻转动画
查看>>
送给即将踏入软考征途的你
查看>>
要命啦!Word中快速录入大全,内含快捷键小技巧,快来一起学习!
查看>>
javascript实现音频mp3播放
查看>>
html5-离线缓存
查看>>
linux系统安装完后的常见工作
查看>>
在Linux服务器、客户端中构建密钥对验证进行远程连接
查看>>
揪出MySQL磁盘消耗迅猛的真凶
查看>>
和“C”的再遇
查看>>