class Solution {
public:
    vector<int>path;
    vector<vector<int>>result;
    int nowlen,target;
    void dfs(TreeNode* root){
        if(root==NULL)return;
        if(root->left==NULL&&root->right==NULL){//叶节点
            if(nowlen+root->val==target){
                path.push_back(root->val);
                result.push_back(path);
                path.pop_back();
            }
            return;
        }
        else{//非叶节点
            path.push_back(root->val);
            nowlen+=root->val;
            dfs(root->left);
            dfs(root->right);
            nowlen-=root->val;
            path.pop_back();
        }
    }
    vector<vector<int>> FindPath(TreeNode* root,int expectNumber) {
        if(root==NULL)return result;
        path.clear();
        nowlen=0;target=expectNumber;
        dfs(root);
        return result;
    }
};