原题题目
代码实现(首刷自解)
class Solution {
public:int visit(int pre,int n){
if(n==1) return pre;int temp = n/2;return visit(pre+temp,n-temp);}int numberOfMatches(int n) {
return visit(0,n);}
};
class Solution {
public:int visit(int pre,int n){
if(n==1) return pre;int temp = n/2;return visit(pre+temp,n-temp);}int numberOfMatches(int n) {
return visit(0,n);}
};