hdu 4223
暴力:
Problem : ( Dynamic Programming? ) Judge Status : Accepted
RunId : Language : C++ Author : yudunfengqing
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define INF 0xfffffff
int a[][];
int b[];
int main()
{
int t,n;
int i,j,k;
scanf("%d",&t);
int _case=;
while(t--)
{
scanf("%d",&n);
for(i=;i<n;i++)
scanf("%d",&b[i]);
int Min=INF;
//for()
for(i=;i<n;i++)
{
a[i][i]=b[i];
Min=min(abs(a[i][i]),abs(Min));
for(j=i+;j<n;j++)
{
a[i][j]=a[i][j-]+b[j];
Min=min(abs(a[i][j]),abs(Min));
}
}
printf("Case %d: %d\n",++_case,abs(Min));
}
}
预处理:
Problem : ( Dynamic Programming? ) Judge Status : Accepted
RunId : Language : C++ Author : yudunfengqing
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define LL __int64
#define INF 0xfffffff
int s[];
int a[];
int main()
{
int i,j,k,n,kk=,t;
cin>>t;
while(t--)
{
cin>>n;kk++;
memset(s,,sizeof(s));
for(i = ; i <= n ; i++)
{
scanf("%d",&a[i]);
s[i] = s[i-]+a[i];
}
int minz=INF;
for(i = ; i <= n ; i++)
for(j = ; j < i ; j++)
{
int x = abs(s[i]-s[j]);
minz = min(minz,x);
}
printf("Case %d: ",kk);
cout<<minz<<endl;
}
return ;
}
hdu 4223的更多相关文章
- HDU 4223 Dynamic Programming?(最小连续子序列和的绝对值O(NlogN))
传送门 Description Dynamic Programming, short for DP, is the favorite of iSea. It is a method for solvi ...
- hdu 4223 Dynamic Programming?
Dynamic Programming? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- hdu 4223 Dynamic Programming? (dp)
//连续的和的绝对值最小 # include <stdio.h> # include <string.h> # include <algorithm> # incl ...
- UVALive - 4223(hdu 2926)
---恢复内容开始--- 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2962 Trucking Time Limit: 20000/10000 MS ...
- UVALive 4223 / HDU 2962 spfa + 二分
Trucking Problem Description A certain local trucking company would like to transport some goods on ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- Question about pairing/bonding?
Except that on android you can bypass the pairing dialog if you know the PIN in advance through a di ...
- [转]Linux Ubuntu上架设FTP
Linux Ubuntu上架设FTP http://www.blogjava.net/stonestyle/articles/369104.html 操作系统:ubuntu (GNU/Linux) 为 ...
- self.a 和 _a 的区别
在OC中我们可以通过指令@property定义属性. OC对属性封装了许多方法,同时也会自动实现一些方法,相比实例变量,感觉更加面向对象些. 一般定义属性的方法如下,在Class Test中定义属性i ...
- 目前国内外主流的linux发行版本
1.linux其实是基于unix发展而来的,还有mac os也是类unix操作系统 2.目前主流的linux发行版本主要有:红帽系列(中国大陆,美洲地区,发源于美国),suse系列(欧洲地区流行,发源 ...
- Liferay IDE3.1 M1的一些新功能
定于11月发布的Liferay IDE提供了一些让人期许的功能 1. code upgrade tools 这个工具将会帮助你把liferay 6.2的项目升级为7.0的项目.下面列举其主要功能 1. ...
- 也发一个自己实现的android简单文件选择器代码。支持多卡,排序
一个很简单的文件选择器对话框,支持双sd卡,当然前提是要有sd卡..并且实现了排序效果. 只有100多行的代码,基本的思路就是用listview显示目录下的所有子文件,再判断是文件还是目录. 利用Co ...
- SQL-AdventureWorks样例数据库
1. 下载样例数据库文件 输入网址:http://www.codeplex.com/ , 搜索:microsoft sql server product samples 下载对应数据库的Adventu ...
- CentOS 6.5下Git服务器搭建
1 . Git服务器搭建 1. 环境部署 系统环境:服务器端:CentOS 6.5 ,ip:192.168.56.1 客户端:CentOS 6.5 ,ip:192.168.56.101 软件版本:服务 ...
- 三分--Football Goal(面积最大)
B - Football Goal Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Su ...
- bzoj 2956 数学展开,分段处理
首先对于答案 ΣΣ(n mod i)*(m mod j) i<>j 也就是Σ(n mod i)Σ(m mod j)-Σ(n mod i)(m mod i) 将mod展开,我们可以得到有fl ...