题意:

从上往下切割,不能切边缘,然后问你两个差值,要小于给出的值。

思路:

直接爆搜,枚举每一行的劈开位置;

#include<bits/stdc++.h>
using namespace std; const int N=1e2+10;
const int INF=0x3f3f3f3f; int n,m;
int sum[N][N];
int ssum,ans; void DFS(int num,int summ)
{
int temp;
for(int i=1;i<m;i++)
{
temp=summ+sum[num][i];
if(num==n)
{
ans=min(ans,abs(temp-ssum+temp));
}
else
DFS(num+1,temp);
}
} int main()
{
int flag;
while(~scanf("%d%d",&n,&m))
{
int dd;
memset(sum,0,sizeof(sum));
ssum=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&dd);
ssum+=dd;
sum[i][j]=sum[i][j-1]+dd;
}
}
scanf("%d",&flag);
ans=INF;
DFS(1,0);
if(ans>flag)
puts("You'd better buy another one!");
else
printf("%d\n",ans);
}
return 0;
}

最新文章

  1. spring boot开发入门
  2. UWP学习记录5-设计和UI之控件和模式2
  3. Yii 读取CVS文件内容插入到数据库
  4. 《Eclipse中的一些快捷键》
  5. Linux chkconfig命令
  6. IHttpModule在webconfig中的注册
  7. AQS 与 LockSupport
  8. java8新特性笔记
  9. C#中的Collection 2
  10. 在stm32上移植wpa_supplicant(一)
  11. 顺序容器的insert使用方法
  12. python测试框架nose
  13. app.config 配置多项 配置集合 自定义配置(3)
  14. Seattle Traffic construction projects punlication
  15. 如何找出单链表中的倒数第k个元素
  16. Go之viper配置
  17. 20155320 Exp9 Web安全基础
  18. bing背单词交互流程 - Chongyang Bai
  19. [转]MySQL DBA面试全揭秘
  20. Elasticsearch 6.x 的分页查询数据

热门文章

  1. makefile编写---.c .cpp 混合编译makefile 模板
  2. Python学习笔记14:标准库之信号量(signal包)
  3. 通过css选择器class给元素添加cursor的坑
  4. EasyPusher实现Android手机屏幕桌面直播,实时推送操作画面,用于手游直播等应用
  5. 页面滚动tab监听
  6. tornado安全应用之cookie
  7. Flyweight Pattern
  8. html5--3.7 input元素(6)
  9. yii的增删改查
  10. 编程模式(schema) —— 表驱动法(table-driven)