当前位置:网站首页>P1163 银行贷款
P1163 银行贷款
2022-08-09 04:21:00 【Star_.】
假设 n为贷款的原值,m为每月支付的分期付款金额,k为分期付款还清贷款所需的总月数,且利率按月累计。
利率为p,则
就好比如,你第一个月的利率为(1+p),第二个月的利率就为(1+p)^2,依次类推。
(银行利率不太懂,简单记录一下)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
double l=0;
double r=10;
double mid=0;
while(r-l>=0.0001){
mid = (l+r)/2;
if(judge(mid,k,n,m)){
l = mid;
}
else
r=mid;
}
System.out.println(String.format("%.1f",mid*100));
}
public static boolean judge(double mid,int k,int n,int m){
double sum=0;
for(int i=1;i<=k;i++){
sum+=(double)1/Math.pow(1+mid,i);
}
return sum>=(double)n/m;
}
}
class Node{
int x,y;
}
class cmp implements Comparator<Node> {
@Override
public int compare(Node o1, Node o2) {
return o1.y - o2.y;
}
}
//快读
class Read{
StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws Exception{
st.nextToken();
return (int)st.nval;
}
}
边栏推荐
猜你喜欢
2022 Security Officer-B Certificate Exam Practice Questions and Online Mock Exam
[math] dot product and cross product
容易混淆的指针知识点
数量遗传学遗传力计算1:亲子回归方法
关于sys.path.append(‘..‘)失效
服务端修改Cookie——跨域cookie发送机——通信加密——异或加密
Construction and practice of full stack code test coverage and use case discovery system
两种K线形态预示今日伦敦银走向
安装pytorch和cuda
串扰与防护
随机推荐
软件质效领航者 | 优秀案例•东风集团DevOps改革项目
Base64编码和图片转化
做现货白银前这些要诀应先记起来
助力To B业务,这类企业端数据值得风控童鞋关注
松柏集(浮窗思)
2022年起重机司机(限桥式起重机)考试题库及模拟考试
了解CV和RoboMaster视觉组(五)图像处理中使用的滤波器
为什么有的时间函数在同一事务内返回的都是同一值?
etcd Study Notes - Getting Started
关于sys.path.append(‘..‘)失效
2022年低压电工练习题及模拟考试
[Server data recovery] A case of data recovery when the Ext4 file system cannot be mounted and an error is reported after fsck
新一代CMDB构建方法,是能够给企业带来收益的
761. 特殊的二进制序列(分治)
记录一次腾讯实习投递经历(一)
【精品向】你真的会写测试用例么?全网超大型测试用例攻略
Improve the user experience and add a small detail to your modal popup
【数学建模绘图系列教程】绘图模板总结
Crosstalk and Protection
union