模拟题,注意:
1、那两个贷款都是向银行贷的,就是两个贷款的总额不能超过70%,就算公积金贷款能贷也不行,我开始的时候以为公积金贷款是向公司借的,,欺负我这些小白嘛....
2、最坑的地方 *0.7是wa的,要*7/10
3、那个公式的-1不是减在月份上的,是减在总体上的
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#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 ",pr_begin,pr_month); return ; } else { pr_month += calc(total,rate_fund,year); pr_begin = price_house - total; printf ("%d %0.0f ",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; }