18. 4Sum(35.07%)

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

Note:
Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d)
The solution set must not contain duplicate quadruplets.
For example, given array S = {1 0 -1 0 -2 2}, and target = 0.

A solution set is:
(-1,  0, 0, 1)
(-2, -1, 1, 2)
(-2,  0, 0, 2)

参考链接:http://www.programcreek.com/2013/02/leetcode-4sum-java/

public class Solution {
    public List<List<Integer>> fourSum(int[] num, int target) {
        Arrays.sort(num);

        HashSet<ArrayList<Integer>> hashSet = new HashSet<ArrayList<Integer>>();
        List<List<Integer>> result = new ArrayList<>();

        for (int i = 0; i < num.length; i++) {
            for (int j = i + 1; j < num.length; j++) {
                int k = j + 1;
                int l = num.length - 1;

                while (k < l) {
                    int sum = num[i] + num[j] + num[k] + num[l];

                    if (sum > target) {
                        l--;
                    } else if (sum < target) {
                        k++;
                    } else if (sum == target) {
                        ArrayList<Integer> temp = new ArrayList<Integer>();
                        temp.add(num[i]);
                        temp.add(num[j]);
                        temp.add(num[k]);
                        temp.add(num[l]);

                        if (!hashSet.contains(temp)) {
                            hashSet.add(temp);
                            result.add(temp);
                        }

                        k++;
                        l--;
                    }
                }
            }
        }

        return result;
    }
}
一、折现率 FCFF 模型中,根据预测期的划分涉及到两个折现率,一个增长率是在其高速增长期所使用的,即加权平均资本成本(WACC),另一个是稳定增长期用到的折现率。其中加权平均资本成本的计算方式如下: (3-13) (3-14) 二、FCFF模型中折现率的确定 在传统的 FCFF 模型中,加权平均资本成本通常用折现率表示。N企业评估期的资本结构如下: 表4-4 负债权益权重 Table 4-4 Debt and equity weights 项目 2017 2018 2019 2020 2021 2022 2023 资产(单位:亿元) 108.9 126.8 131.9 142.8 128.3 142.8 182.0 负债(单位:亿元) 47.30 65.27 68.45 85.21 96.95 109.9 129.1 所有者权益(单位:亿元) 61.6 61.53 63.45 57.59 31.35 32.9 52.9 负债权重 43.43% 51.47% 51.90% 59.67% 75.57% 76.96% 70.93% 所有者权益权重 56.57% 48.53% 48.10% 40.33% 24.43% 23.04% 29.07% 基于N公司过往的资本结构数据,我们可以发现其负债与所有者权益在总资产中的占比平均值分别为 61.42% 38.58%。随后,通过加权平均资本成本(WACC)的计算方法,我们将这两个比例与相应的资本成本进行相乘并求,从而得到折现率(WACC):3.66%*61.42%+6.12%*38.58%=WACC。 三、将WACC代入估值模型 第一种情况估值: V1=3.05/((WACC-3%)(1+WACC)3)+8.04/WACC 第二种情况估值: V2=3.96/((WACC-3%)(1+WACC)3)+10.08/WACC 第三种情况估值: NPV=3.77*1.03/(WACC-3%) V3=3.04/(1+WACC)+3.39/(1+WACC)2+3.77/(1+WACC)3+NPV/(1+WACC)3 具体需求:使用MATLAB设计粒子群算法优化WACC,找到一个WACC的值,保证WACC取值范围在3%-6%之间即可,然后将得出的WACC值代入三种估值情况模型中,使得V2更加接近229.89,V1其次,V3最后,且V1、V2、V3与229.89相差在20以内。
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值