| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 728 人关注过本帖
标题:不懂题目什么意思,请教高手
只看楼主 加入收藏
hugh2006
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-7-12
收藏
 问题点数:0 回复次数:4 
不懂题目什么意思,请教高手
Problem A. Matrix
Description:

    Given an n*n matrix A, whose entries Ai,j are integer numbers ( 0 <= i < n, 0 <= j < n ). An operation SHIFT at row i ( 0 <= i < n ) will move the integers in the row one position right, and the rightmost integer will wrap around to the leftmost column.

 

    You can do the SHIFT operation at arbitrary row, and as many times as you like. Your task is to minimize

max0<=j< n{ Cj | Cj=Σ0<=i<n Ai,j }   

Input:

    The input consists of several test cases. The first line of each test case contains an integer n. Each of the following n lines contains n integers, indicating the matrix A. The input is terminated by a single line with an integer −1. You may assume that 1 <= n <= 7 and |Ai,j| < 104.

Output:

    For each test case, print a line containing the minimum value of the maximum of column sums.

Sample Input:

2
4 6
3 7
3
1 2 3
4 5 6
7 8 9
-1
Sample Output:

11
15
搜索更多相关主题的帖子: operation position numbers around matrix 
2008-07-13 18:22
xin222
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-6-17
收藏
得分:0 
题目A  矩阵

描述:
    给定一个n行n列的矩阵A,矩阵元素为整型数字,用Ai,j表示第i行j列的元素。对某一行的操作SHIFT实现把该行的元素往右移一位,最右边的数字移到最左边。
    你可以对任意行作SHIFT操作任意次,最终使得各纵列数字的和中最大的那一个最小。

输入:
    可以一次输入几个矩阵,每一个矩阵的输入格式为,第一行为表示行列数的数字n,接下来的n行每行有n个数字,表示矩阵中的元素。最后以-1作为单独一行结束输入。可以假设1<=n<=7,|Ai,j|<=104

输出:
    对于每一个矩阵输出一行结果,结果内容为该矩阵调整之后各纵列之和的最大值。

下面是一个输入输出的例子:
Sample Input:

2
4 6
3 7
3
1 2 3
4 5 6
7 8 9
-1
Sample Output:

11
15
2008-07-13 20:25
hugh2006
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-7-12
收藏
得分:0 
知道了,谢谢
2008-07-14 00:34
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1029
专家分:177
注 册:2007-5-10
收藏
得分:0 
1 <= n <= 7 说明这是一道硬搞题。
2008-07-14 02:04
xin222
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-6-17
收藏
得分:0 
我试着写了一下。

//矩阵类
class CMatrix
{
public:
    int m_n;                   //矩阵行、列数(本程序中使用的矩阵为方阵)
    int m_matrix[7][7];        //储存矩阵元素的数组
    int m_sumclo[7];           //记录纵列数字之和
    int m_maxsum;              //纵列数字之和的最大值
public:
    void SHIFT(int i);         //实现将第j行元素向右移一位
    void Adjustment();         //调整矩阵使其纵列之和的最大值最小
public:
    CMatrix(void);
public:
    ~CMatrix(void);
};

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#include "Matrix.h"
#include "math.h"

void CMatrix::SHIFT(int i)
{
    int j;
    int temp;
    temp=m_matrix[i][m_n-1];
    for(j=m_n-1;j>0;j--)
    {
        m_matrix[i][j]=m_matrix[i][j-1];
    }
    m_matrix[i][0]=temp;
}
void CMatrix::Adjustment()
{
    int i,j,k;
    int max;
    int turn[7]={0};
    m_maxsum=-1;
    for(i=0;i<(int)pow((double)m_n,(double)m_n);i++)
    {
        for(j=0;j<m_n;j++)
        {
            m_sumclo[j]=0;
            for(k=0;k<m_n;k++)
            {
                m_sumclo[j]+=m_matrix[k][j];
            }
        }
        max=0;
        for(j=0;j<m_n;j++)
        {
            if(m_sumclo[j]>max)
            {
                max=m_sumclo[j];
            }
        }
        if(m_maxsum==-1)
        {
            m_maxsum=max;
        }
        else
        {
            if(m_maxsum>max)
            {
                m_maxsum=max;
            }
        }
        SHIFT(0);
        turn[0]++;
        for(j=0;j<m_n;j++)
        {
            if(turn[j]==m_n)
            {
                turn[j]=0;
                SHIFT(j+1);
                turn[j+1]++;
            }
        }
    }
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#include "Matrix.h"
#include <iostream>
using namespace std;
int main()
{
    int i,j;
    int n;
    int num=0;
    CMatrix matrix[7];
    cout<<"请输入:"<<endl;
    while(1)
    {
        cin>>n;
        if(n==-1)
        {
            break;
        }
        if(0<n&&n<=7)
        {
            matrix[num].m_n=n;
            for(i=0;i<n;i++)
            {
                for(j=0;j<n-1;j++)
                {
                    cin>>matrix[num].m_matrix[i][j];
                }
                cin>>matrix[num].m_matrix[i][j];
            }
            num++;
        }
        else
        {
            cout<<"输入出错!"<<endl;
            break;
        }
    }
    for(i=0;i<num;i++)
    {
        matrix[i].Adjustment();
        cout<<matrix[i].m_maxsum<<endl;
    }
    return 0;
}
2008-07-14 08:31
快速回复:不懂题目什么意思,请教高手
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012027 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved