HDU 4708 Rotation Lock Puzzle 解题报告
来源:互联网 发布:海尔网络电视机 编辑:程序博客网 时间:2024/05/20 01:08
题目
比赛
题意:
一个n×n(n为奇数)的矩阵,每一圈可以每次顺时针或者逆时针转一格,求最大的两条对角线上的数字和,且求最少的转动次数。
题解:
对于格子(i,j)其它三个和它会同时在对角线上的格子是(j,n-i-1) (n-i-1,n-j-1) (n-j-1,i)。直接加就行。
//Time:15ms//Memory:368KB#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;const int MAXN= 20;const double EPS = 1e-8;const double INF = 1e50;long long ma[MAXN][MAXN];int main(){ //freopen("/home/moor/Code/input","r",stdin); int n; long long a,b; while(scanf("%d",&n)&&n) { a=0,b=0; for(int i=0;i<n;++i) for(int j=0;j<n;++j) cin>>ma[i][j]; for(int i=0;i<n;++i) { long long tmp=0,len=0,tt; for(int j=i;j<n-1-i;++j) { tt=ma[i][j]+ma[j][n-i-1]+ma[n-i-1][n-j-1]+ma[n-j-1][i]; if(tt>tmp) tmp=tt,len=min(j-i,n-j-1-i); else if(tt==tmp) len=min(len,(long long)min(j-i,n-j-1-i)); } a+=tmp,b+=len; } a+=ma[n/2][n/2]; cout<<a<<' '<<b<<'\n'; } return 0;}
- HDU 4708 Rotation Lock Puzzle 解题报告
- hdu - 4708 - Rotation Lock Puzzle
- hdu 4708 Rotation Lock Puzzle
- HDU 4708 Rotation Lock Puzzle
- hdu 4708 Rotation Lock Puzzle
- HDU 4708 Rotation Lock Puzzle
- HDU 4708 Rotation Lock Puzzle
- HDU 4708 Rotation Lock Puzzle
- hdu 4708 Rotation Lock Puzzle
- HDU 4708:Rotation Lock Puzzle
- hdu 4708 Rotation Lock Puzzle(模拟)
- Hdu 4708 Rotation Lock Puzzle --模拟
- HDU 4708 Rotation Lock Puzzle (热身赛第三题)
- HDU 4708 Rotation Lock Puzzle(数学啊)
- hdu4708 Rotation Lock Puzzle
- HDU 4708 Rotation Lock Puzzle && 2013 ACM/ICPC Asia Regional Online —— Warmup
- hdu 4708 Rotation Lock Puzzle 2013年ICPC热身赛A题 旋转矩阵
- 2013杭电warm up1 Rotation Lock Puzzle
- 计词unigram和bigram的频次
- dev、devfs、 udev和sysfs之间的关系
- 数独 RUBY 算法、baltctf-2013-sudoku
- HIbernate中的乐观锁与悲观锁
- hdu 4710 Balls Rearrangement
- HDU 4708 Rotation Lock Puzzle 解题报告
- 大数据时代的技术hive:hive介绍
- Viewport.js + C_Frame.js
- 指针间的关系
- Android SDK Manager 下载问题
- 自己动手写脚本语言
- 为什么sizeof取不到extern的数组大小
- EL表达式
- 内存中的变量