zoukankan      html  css  js  c++  java
  • 问题 1003

    题目描述

    Alice and Bob are playing a game. Firstly, Bob writes several numbers on a chessboard, which is a n*m matrix. Then, it is Alice’s turn to operate. In Every operation, he is allowed to plus or minus a random number to the two adjoining squares. now, Alice wants to know whether there is an operation which can change all the number of the chessboard into zeros.

    输入

    The first line contains an integer T(1 <= T <= 10), indicating the number of test cases.For each test case there is a line,contains two integer n,m(1<=n,m<=500), and next n lines,each line contain m integers,indicating the matrix.

    输出

    For each test case,if Alice can change all the number of the chessboard into zeros, then print "Yes", or print "No"

    样例输入

    2 1 1 1 2 2 3 4 6 7

    样例输出

    No Yes
     
     
    开始一直不对,后面发现因为数据溢出了……伤感……
     
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    int main()
    {
         int  a;
         scanf( "%d", &a );
         while( a-- )
         {
             int n, m, f[1000][1000];
              scanf( "%d%d", &n, &m );
              int i, j, t, sum[1000];
              for( i = 0; i < n; i++ )
                 for( j = 0; j < m; j++ )
                    scanf( "%d", &f[i][j] );
             for( i = 0; i < n; i++ )
                 for( j = 0; j < m - 1; j++ )
                      f[i][j++] -= f[i][j];
              for( i = 0; i < n - 1; i++ )
                   f[i++][j] -= f[i][j];
              if( f[i++][j] == 0 )
                 printf( "Yes\n" );
              else
                 printf( "No\n" );
          }
    }
  • 相关阅读:
    在Intellij idea 2017中运行tomcat 8.5
    Servlet技术之服务器的安装和配置
    Servlet&&Jsp 概述
    linux 下 tomcat 安装
    执行数据库的更新操作
    JDBC
    Mysql 命令
    hdoj2036 改革春风吹满地——叉积
    常规设置
    pytorch本地安装
  • 原文地址:https://www.cnblogs.com/zsj576637357/p/2284218.html
Copyright © 2011-2022 走看看