1、喝汽水问题。每7个汽水瓶可以换一瓶汽水,输入为n瓶汽水,求得最后能喝到多少瓶汽水
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
public static int count(int n){ return n+emptyCount(n); } public static int emptyCount(int m) { int empty; int currentStreamWater=m/7; if (m < 7) { return 0; } if (m % 7 == 0) { empty = currentStreamWater; } else { empty = currentStreamWater + m % 7; } return currentStreamWater+emptyCount(empty); }
2、已知A B两个数组,构造新的集合S={x+y | x属于A, y属于B} 求S中最小的k个元素,最优解法