HDU 4500 Tencent marathon No. 1

Source: Internet
Author: User
Question # include <iostream> # include <cstring> # include <cmath> using namespace STD; int Ki [23] [23]; int value [23] [23]; int n, m; int cal_val (int x, int y) {If (x * Y <0) return ABS (y); else if (x * Y> 0) return-ABS (y); elsereturn 0;} int main () {While (CIN> N> m) {If (n = 0 & M = 0) break; memset (value, 0, sizeof (value); memset (KI, 0, sizeof (Ki); For (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= m; j ++) {CIN> Ki [I] [J]; value [I] [J] = 0 ;}for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= m; j ++) {value [I] [J] + = cal_val (KI [I] [J], Ki [I-1] [J]); value [I] [J] + = cal_val (KI [I] [J], Ki [I + 1] [J]); value [I] [J] + = cal_val (KI [I] [J], Ki [I] [J-1]); value [I] [J] + = cal_val (KI [I] [J], Ki [I] [J + 1]) ;}} int MX = 1, my = 1; int max = value [1] [1]; for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= m; j ++) {If (value [I] [J]> MAX) {max = value [I] [J]; MX = I; my = J ;}}cout <MX <"" <my <"" <value [MX] [my] <Endl ;}return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.