ZOJ-1760
2013-12-19 21:00
183 查看
感觉应该还有更好的算法,反正说就15个数,O(n^2)遍历也无所谓了。。
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == -1) break; ArrayList<Integer> source = new ArrayList<Integer>(); ArrayList<Integer> res = new ArrayList<Integer>(); while (n != 0) { source.add(n); if (n % 2 == 0) res.add(n / 2); n = sc.nextInt(); } int result = 0; for (Integer i : res) for (Integer ii : source) if (i == ii) { result++; break; } System.out.println(result); } } }
相关文章推荐
- ZOJ 1760 How Many Shortest Path
- zoj 1760 Doubles
- ZOJ 1760 多少个两倍数
- zoj 1760 Doubles
- POJ 1552 & ZOJ 1760 & UVA2787
- ZOJ Problem Set–1760 Doubles
- ZOJ 1760 Doubles
- zoj 1760 查找
- ZOJ Problem Set - 1760 Doubles
- zoj 1760 Doubles
- ZOJ 1760
- zoj 1760 Doubles(set集合容器的应用)
- ZOJ 1760 How Many Shortest Path(最短路+网络流之最大流)
- zoj 1760 Doubles
- zoj 1760.Doubles
- ZOJ 1760 How Many Shortest Path (网络流.水)
- ZOJ 1760 &&POJ1552 Doubles (模拟)
- zoj 1760 Doubles
- zoj 1760 floyd构图+Dinic最大流
- zoj 2050 || poj 1753 Flip Game(状态压缩 简单BFS)