HDUOJ---(4708)Rotation Lock Puzzle
Rotation Lock Puzzle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 695 Accepted Submission(s): 204
9 3 2 5 9
7 4 7 5 4
6 9 3 9 3
5 2 8 7 2
9 9 4 1 9This 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).
#include<iostream>
#include<cstdio>
using namespace std;
int min(int a,int b)
{
return a<b?a:b;
}
int main()
{
int n,i,j,max,pos,tpos;
int str[][],sum;
while(cin>>n,n)
{
for(i=;i<=n;i++) //输入部分
{
for(j=;j<=n;j++)
scanf("%d",str[i]+j);
}
pos=;
max=str[(n+)/][(n+)/];
for(i= ; i<=(n-)/ ; i++) //圈数
{
for(j=i;j<=n-i;j++)
{
int temp=(str[j][i]+str[n-j+][n-i+])+(str[n-i+][j]+str[i][n-j+]); //主副对角线相加
if(j==i||sum<temp)
sum=temp,tpos=min(j-i,n-(i+j)+);
}
pos+=tpos;
max+=sum;
}
printf("%d %d\n",max,pos);
}
return ;
}
HDUOJ---(4708)Rotation Lock Puzzle的更多相关文章
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- HDU 4708:Rotation Lock Puzzle
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 4708 Rotation Lock Puzzle (简单题)
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 4708 Rotation Lock Puzzle(模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 题目大意:给定一个方形矩阵,边长为3-10的奇数.每一圈的数字可以沿着顺时针方向和逆时针方向旋转 ...
- hdu 4708 Rotation Lock Puzzle 2013年ICPC热身赛A题 旋转矩阵
题意:给出一个n*n的矩阵,旋转每一圈数字,求出对角线可能的最大值,以及转到最大时的最小距离. 只要分析每一层就可以了,本来想用地址传递二维数组,发现行不通,改了一下就行了. 这里有个坑,比如: 1 ...
- hdu4708 Rotation Lock Puzzle
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Rotation Lock Puzzle
Problem Description Alice was felling into a cave. She found a strange door with a number square mat ...
- Codeforces Round #467 (Div. 2) E -Lock Puzzle
Lock Puzzle 题目大意:给你两个字符串一个s,一个t,长度<=2000,要求你进行小于等于6100次的shift操作,将s变成t, shift(x)表示将字符串的最后x个字符翻转后放到 ...
- Codeforces Round #467 (Div. 1). C - Lock Puzzle
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> ...
随机推荐
- Android之Bean属性通知类
调用: import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import android. ...
- 解决hue报错:timed out (code THRIFTSOCKET): None
报错栈: [/Jun/ :: +] decorators ERROR error running <function execute at 0x7fba2804ecf8> Tracebac ...
- JAVA常见算法题(三十三)---求子串在字符串中出现的次数
计算某字符串中子串出现的次数. public static void main(String[] args) { String s1 = "adcdcjncdfbcdcdcd"; ...
- 深度学习阅读列表 Deep Learning Reading List
Reading List List of reading lists and survey papers: Books Deep Learning, Yoshua Bengio, Ian Goodfe ...
- 【BZOJ】【3503】【CQOI2014】和谐矩阵
高斯消元解Xor方程组 Orz ZYF o(︶︿︶)o 唉我的数学太烂了…… 错误思路:对每个格点进行标号,然后根据某5个异或和为0列方程组,高斯消元找自由元……(目测N^3会TLE) ZYF的正确思 ...
- BZOJ 4145 [AMPPZ2014] The Prices 解题报告
感觉也是一个小清新题.. 我们考虑设立状态 $Dp[i][s]$ 表示考虑了前 $i$ 个商店后,购买状态为 $s$ 的最小花费. 转移的话就枚举每个商店 $i$,首先令: $$Dp[i][s] = ...
- 我也用github(2)——关联本地工程到github仓库
github只是为我们提供了一个存储的功能,我们也可以准备一个服务器(当然,能联网是前提了),将版本库保存到服务器上. 本文以github为例进行实验. 1. 在github上创建一个仓库 这个非常简 ...
- 用VLC读取摄像头产生RTSP流,DSS主动取流转发(一)(二) 【转】
http://blog.csdn.net/fm0517/article/details/38110633 http://blog.csdn.net/fm0517/article/details/381 ...
- SQL Server基础知识三十三问 (7-14)
8. 一般什么时候使用update_statistics命令? 答: 这个命令基本上是在很多数据被处理过了之后才使用的. 如果大量的删除, 修改, 或这大量的数据插入已经发生了, 那么index就需 ...
- Template Method 模板方法 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...