【模拟】FOJ 2244 Daxia want to buy house

题目链接:

  http://acm.fzu.edu.cn/problem.php?pid=2244

题目大意:

  每月还款额=贷款本金×[月利率×(1+月利率)^还款月数]÷[(1+月利率)^还款月数-1]

  由于商业贷款利率高于公积金贷款利率,优先公积金贷款,超出部分再采用商业贷款.

  银行至多给予贷款总额最多不超过70%,且数额必须为万的整数倍,daxia想尽量少首付多贷款.

题目思路:

  【模拟】

  直接模拟就行,连快速幂都可以不用。

  注意不能*0.7要*7/10!!!!!!

 

 

 1 //
 2 //by coolxxx
 3 //#include<bits/stdc++.h>
 4 #include<iostream>
 5 #include<algorithm>
 6 #include<string>
 7 #include<iomanip>
 8 #include<map>
 9 #include<memory.h>
10 #include<time.h>
11 #include<stdio.h>
12 #include<stdlib.h>
13 #include<string.h>
14 //#include<stdbool.h>
15 #include<math.h>
16 #define min(a,b) ((a)<(b)?(a):(b))
17 #define max(a,b) ((a)>(b)?(a):(b))
18 #define abs(a) ((a)>0?(a):(-(a)))
19 #define lowbit(a) (a&(-a))
20 #define sqr(a) ((a)*(a))
21 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
22 #define mem(a,b) memset(a,b,sizeof(a))
23 #define eps (1e-8)
24 #define J 10
25 #define MAX 0x7f7f7f7f
26 #define PI 3.14159265358979323
27 #define N 224
28 using namespace std;
29 typedef long long LL;
30 int cas,cass;
31 int n,m,lll,ans;
32 double mi(double x,int y)
33 {
34     double sum=1;
35     while(y)
36     {
37         if(y&1)sum=sum*x;
38         x=x*x;
39         y>>=1;
40     }
41     return sum;
42 }
43 int main()
44 {
45     #ifndef ONLINE_JUDGE
46 //    freopen("1.txt","r",stdin);
47 //    freopen("2.txt","w",stdout);
48     #endif
49     int i,j,k,y,dk,dk1,dk2;
50     double r1,r2,y1,y2;
51 //    for(scanf("%d",&cas);cas;cas--)
52 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
53     while(~scanf("%d",&n))
54 //    while(~scanf("%d",&n))
55     {
56         scanf("%d",&m);
57         scanf("%lf%lf",&r1,&r2);
58         scanf("%d",&y);y=y*12;
59         dk=n*7/10;r1/=1200;r2/=1200;
60         dk2=min(dk,m);dk1=dk-dk2;
61         n-=dk;
62         y1=mi(1+r1,y);
63         y1=10000*dk1*r1*y1/(y1-1);
64         //if(int(y1*10)%10>=5)y1+=1;
65         y2=mi(1+r2,y);
66         y2=10000*dk2*r2*y2/(y2-1);
67         //if(int(y2*10)%10>=5)y2+=1;
68         printf("%d %d\n",n,int(y1+y2+0.5000001));
69     }
70     return 0;
71 }
72 /*
73 //
74 
75 //
76 */
View Code

 

posted @ 2016-08-18 18:11  Cool639zhu  阅读(247)  评论(0编辑  收藏  举报