NYOJ之题目325 zb的生日
2016-12-21 21:39
369 查看
--------------------------------------
刷一辈子水题...
AC代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()){ int n=sc.nextInt(); int x[]=new int ; while(--n>=0) x =sc.nextInt(); int ans=dfs(x,0,0,0); System.out.println(ans); } } public static int dfs(int x[],int index,long s1,long s2){ if(index==x.length) return (int) Math.abs(s1-s2); return Math.min(dfs(x,index+1,s1+x[index],s2), dfs(x,index+1,s1,s2+x[index])); } }
题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=325
相关文章推荐
- 文件的创建 读取 写入知识点
- Java编译(二) Java前端编译:Java源代码编译成Class文件的过程
- 从零开始学写HTTP服务器(五)IO复用使用epoll
- web开发基础
- Hibernate 配置文件中的方言
- c语言字符串总结
- BZOJ 3505: [Cqoi2014]数三角形
- JDK提供的四种线程池代码详解
- 数据结构---二叉树
- 资源的GPUAddress
- Jetty学习四:部署到Jetty
- bzoj 4016: [FJOI2014]最短路径树问题
- 【Codeforces 629 B Far Relative’s Problem】
- spring mvc 再次入门遇到的困惑
- oracle数据库从入门到精通之三
- 学习小记 - Python爬虫 (1) 静态网页糗事百科的爬取
- css 水平居中 margin:0 auto
- android-----Android Studio 插件Plugin Error找不到的问题
- 思考总结 Labview
- 尽吾志矣,然不能至者,可以无悔!