URAL 1005 Stone Pile (DFS)
来源:互联网 发布:网络借钱最快的地方 编辑:程序博客网 时间:2024/04/28 11:08
#include <stdio.h>#define ABS(x) ( (x) > 0 ? (x) : -(x) )#define INF (1 << 31 - 1)#define MAX_STONES (20 + 1)#define MAX_WEIGHT (100000)int numOfStones;int weights[MAX_STONES];int totalWeigh;int minDifferOfWeight = INF;void DFS(int depth, int currentWeigh){ if (depth == numOfStones){ if (ABS(totalWeigh - currentWeigh - currentWeigh) < minDifferOfWeight) minDifferOfWeight = ABS(totalWeigh - currentWeigh - currentWeigh); return; } DFS(depth + 1, currentWeigh + weights[depth + 1]); DFS(depth + 1, currentWeigh);}int main(){ scanf("%d", &numOfStones); int indexOfStone; for (indexOfStone = 1; indexOfStone <= numOfStones; indexOfStone++){ scanf("%d", &weights[indexOfStone]); totalWeigh += weights[indexOfStone]; } DFS(0, 0); printf("%d", minDifferOfWeight); return 0;}
0 0
- URAL 1005 Stone Pile (DFS)
- ural 1005 stone pile
- ural 1005 Stone Pile
- URAL 1005 Stone Pile
- URAL 1005 Stone Pile
- URAL 1005 Stone Pile
- ural 1005 Stone Pile
- URAL 1005 Stone Pile
- URAL 1005 Stone Pile
- ural 1005 Stone Pile
- ural 1005 Stone Pile 01背包或dfs
- URAL——1005 stone pile
- ural 1005. Stone Pile
- ural 1005. Stone Pile dp
- timus 1005 stone pile
- Ural-1005. Stone Pile(简单01背包)
- ural 1005. Stone Pile -01背包-dp
- DFS水一发Stone Pile Ural_1005
- Netty系列之Netty线程模型
- syslog
- git初步了解和学习
- 模态框
- <context:component-scan>使用说明 接上一篇 自己理解方面所写
- URAL 1005 Stone Pile (DFS)
- 可变参数
- Java规则引擎详解
- LightOJ 1094 - Farthest Nodes in a Tree【树的直径】
- Introduction to Java Programming编程题8.36<Latin square>
- java远程发送文件到服务器(jcifs.smb实现方式)
- Android视频采集编码颜色格式选择
- 喷水装置 ACM题目 京东16招聘编程题(贪心算法)
- JSP/SERVLET入门教程--Servlet 使用入门