- 浏览: 70599 次
- 性别:
- 来自: 杭州
最新评论
参考了别人的思路才搞定。见http://blog.csdn.net/acm_davidcn/article/details/5834454
使用了最大连续子序列和的算法,虽然自己也知道这个算法,但是却没办法做到活学活用。
/* zoj 1074 To the Max */ #include <stdio.h> #include <string.h> #include <limits.h> #define MAX 105 int main(void) { int i,j,k; int a[MAX][MAX]; int matrixSize,sum,max = INT_MIN; memset(a,0,sizeof(a)); scanf("%d", &matrixSize); for(i = 1; i <= matrixSize; i++) for(j = 1; j <= matrixSize; j++) { scanf("%d", &a[i][j]); a[i][j] += a[i-1][j]; } for(i = 1; i <= matrixSize; i++) for(j = i; j <= matrixSize; j++) { sum = 0; for(k = 1; k <= matrixSize; k++) { sum += a[j][k]-a[i-1][k]; if(sum < 0) sum = 0; if(sum > max) max = sum; } } printf("%d\n",max); return 0; }
发表评论
-
最小c编译器
2011-11-08 14:09 1425最小c编译器(来源 (最好在linux下操作))代码有好几个 ... -
the development of c language(转)
2011-11-08 09:25 1106c语言之父Dennis Ritchie 写的关于c语言开发历 ... -
C语言,你真的弄懂了么?
2011-11-07 12:42 1727程序(来源 ): #include <stdi ... -
pe文件格式实例解析
2011-11-07 10:05 0环境:windows xp 速龙3000+(即x86兼容32位 ... -
小型elf "Hello,World"程序
2011-11-06 23:59 1325参考链接:http://timelessname.com/el ... -
elf文件格式实例解析
2011-11-05 23:00 6285试验环境:archlinux 速龙3000+(即x86兼 ... -
高质量的c源代码
2011-11-03 10:18 1097现在自由软件及开源软件越来越流行,有大量的附带源程序 ... -
fltk 库
2011-09-26 19:47 1773fltk是一个小型、开源、支持OpenGL 、跨平台(win ... -
《Introduction to Computing Systems: From bits and gates to C and beyond》
2011-09-25 23:33 2118很好的一本计算机的入门书,被很多学校采纳作为教材,作者Yale ... -
csapp bufbomb实验
2011-09-16 14:21 4550csapp (《深入理解计算机系统》)一书中有一个关于缓冲区 ... -
the blocks problem(uva 101 or poj 1208)
2011-09-11 20:57 1805题目描述见:uva 101 or poj 1208 ... -
the blocks problem(uva 101 or poj 1208)
2011-09-11 20:56 0题目描述见:uva 101 or poj 1208 ... -
部分排序算法c语言实现
2011-09-02 14:51 989代码比较粗糙,主要是用于对排序算法的理解,因而忽略了边界和容错 ... -
编译器开发相关资源
2011-08-31 08:40 1173开发编译器相关的一些网络资源: how difficu ... -
zoj 1025 Wooden Sticks
2011-07-23 20:25 944题目见:zoj 1025 先对木棒按照长度进行排序,然后再计 ... -
zoj 1088 System Overload
2011-07-23 17:30 1139约瑟夫环 (josephus problem )问题, ... -
zoj 1091 Knight Moves
2011-07-23 09:05 819题目见zoj 1091 使用宽度搜索优先来求解, ... -
zoj 1078 palindrom numbers
2011-07-22 19:31 1120题目见zoj 1078 主要是判断一个整数在基数为2 ... -
zoj 1006 do the untwist
2011-07-22 13:24 902题目见zoj 1006 或poj 1317 简单 ... -
zoj 3488 conic section
2011-07-22 12:23 970题目见zoj 3488 很简单的题目,却没能一次搞定,因 ...
相关推荐
zoj吐血制作,希望大家喜欢
zoj 1610 Count the Colors.md
zoj 1255 The Path.md
ZOJ解题报告ZOJ解题报告ZOJ解题报告ZOJ解题报告
zoj题目简单归类zoj题目简单归类zoj题目简单归类
zoj 1810 The Gourmet Club.md
zoj 2499 The Happy Worm.md
zoj 2151 The Highest Profits.md
acm中zoj1002的可运行C++程序
包含了zoj700多道题目的源代码,在做题时可以参考
To prevent other companies from revealing his secret, he decided to use a substitution cipher in all the letters mentioning the new play. Substitution cipher is defined by a substitution table ...
Problem Arrangement zoj 3777
ZOJ题目答案源码
zoj 1566 Too Lazy To Move.md
一个非常非常非常非常实用的zoj结题代码
ZOJ1805代码
It costs R yuans for the theatre to run each show, and S yuans to serve each of the audiences during each show. Now your job is to write a program to maximize the total revenue of each show for the ...
zoj 1003 c语言的,要写这么多描述吗。。
学习ACM程序设计的朋友一定要看,这是训练必备的POJ ZOJ题目分类及解题思路
本代码是zoj上AC的1951的代码,把双重循环简化为O(n),不过素数判断的改进还不够