摘要: 将1000个魔法石头放到10个袋子中,要求通过组合10个袋子中的不同袋子,可以得到1-1000之间任意个数的魔法石头,可以可以的方案是: 1,2,4,8,16,32,64,128,256,512,1000-(前面的魔法石头的数量) 阅读全文
posted @ 2018-05-11 18:04 最美遇见你 阅读(201) 评论(0) 推荐(0)
摘要: 循环的终止条件while(L<=R) 阅读全文
posted @ 2018-05-11 17:59 最美遇见你 阅读(261) 评论(0) 推荐(0)
摘要: //对于递归的折半查找,需要考虑找不到的情况。 #include #include #include #define maxn 10001 using namespace std; int a[maxn],key; //折半查找法---递归二分法 int search(int s,int e) { int mid; if(e>=s) { mid=(s... 阅读全文
posted @ 2018-05-11 17:36 最美遇见你 阅读(236) 评论(0) 推荐(0)