FZU Problem 2244 Daxia want to buy house

本文介绍了一道关于房贷计算的模拟题,详细解释了题目中容易误解的地方,并提供了一个C++实现的房贷计算器代码示例。该代码可以计算商业贷款和公积金贷款的月还款额,帮助理解贷款总额不超过房产价格70%的限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模拟题,注意:

1、那两个贷款都是向银行贷的,就是两个贷款的总额不能超过70%,就算公积金贷款能贷也不行,我开始的时候以为公积金贷款是向公司借的,,欺负我这些小白嘛....

2、最坑的地方 *0.7是wa的,要*7/10

3、那个公式的-1不是减在月份上的,是减在总体上的

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
int price_house,max_fund;
double rate_bussiness,rate_fund;
int year;
double calc (int all,double rate,int mon)
{
    all *= 10000;
    mon *= 12;
    rate /= 100;
    rate /= 12;
    double ans = all*(rate*pow(1+rate,mon*1.0))/(pow(1+rate,mon*1.0)-1);
    return ans;
}
void work ()
{
    //cout<<calc(107,rate_bussiness,20)<<endl;
    int total = (int)floor(0.7*price_house);
    int pr_begin=0;
    double pr_month=0;
    if (total >= max_fund)
    {
        total -= max_fund;
        pr_month += calc(max_fund,rate_fund,year);
        pr_month += calc(total,rate_bussiness,year);
        pr_begin = price_house - total - max_fund;
        printf ("%d %0.0f\n",pr_begin,pr_month);
        return ;
    }
    else
    {
        pr_month += calc(total,rate_fund,year);
        pr_begin = price_house - total;
        printf ("%d %0.0f\n",pr_begin,pr_month);
    }
    return ;
}
int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    while(scanf("%d%d%lf%lf%d",&price_house,&max_fund,&rate_bussiness,&rate_fund,&year)!=EOF)
        work();
    return 0;
}
View Code

 

转载于:https://www.cnblogs.com/liuweimingcprogram/p/5785109.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值