博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDUOJ------2398Savings Account
阅读量:6546 次
发布时间:2019-06-24

本文共 1687 字,大约阅读时间需要 5 分钟。

Savings Account

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 779    Accepted Submission(s): 545


Problem Description
Suppose you open a savings account with a certain initial balance. You will not make any withdrawals or further deposits for a number of years. The bank will compound your balance (add the annual interest) once a year, on the anniversary of the opening of the account. Your goal is to achieve a certain target amount in your savings account. In how may years will the target amount be achieved?
 

 

Input
The input file will contain data for one or more test cases, one test case per line. Each line will contain three numbers: the initial balance, the annual interest rate (as a percentage of the balance), and the target amount, separated by blank spaces. These will be positive numbers; they may or may not contain a decimal point. The target amount will be greater than the initial balance. The input is terminated by end-of-file
 

 

Output
For each line of input, your program will produce exactly one line of output: This line will contain one positive integer value: the number of years required to achieve the target amount.
 

 

Sample Input
200.00 6.5 300 500 4 1000.00
 

 

Sample Output
7 18
 

 

Author
2006Rocky Mountain Warmup
 

 

Source
水体:
代码:
1 #include
2 #include
3 #include
4 int main() 5 { 6 double a,r,tot; 7 int cnt=0; 8 while(scanf("%lf%lf%lf",&a,&r,&tot)!=EOF) 9 {10 r/=100;11 while(tot-a>1.0e-8)12 {13 cnt++;14 a*=(r+1);15 }16 printf("%d\n",cnt);17 cnt=0;18 }19 return 0;20 }

 

转载地址:http://keedo.baihongyu.com/

你可能感兴趣的文章
POJ 3468 A Simple Problem with Integers(线段树 区间更新)
查看>>
安装apr-1.6.3报错[cannot remove `libtoolT’: No such file or directory]解决方法
查看>>
C# 操作Excel,控制格式[转]
查看>>
iOS开发中一些常用的属性
查看>>
Git 使用教程
查看>>
spring--基于ioc的配置文件方式
查看>>
“小 U”- UI自动化测试平台 [自动化测试平台开发实战 - 基于 Spring Boot + Kotlin]...
查看>>
Vue使用过程中的可能会遇到的几个问题
查看>>
TIMO 后台管理系统 v2.0.1 发布,加入 jwt 身份验证组件,基于 Spring Boot
查看>>
Java 11 将至,不妨了解一下 Oracle JDK 之外的版本
查看>>
Log4j_学习_03_自己动手封装log工具
查看>>
Redis的各项功能解决了哪些问题?
查看>>
FastAdmin 极速后台管理框架 1.0.0.20190301_beta
查看>>
Selenium2 WebDriver 启动Chrome, Firefox, IE 浏览器、设置profile&加载插件
查看>>
Python标准库01 正则表达式(re包)
查看>>
Hello,Java女神
查看>>
rpc远程调用开发
查看>>
复习-css控制文本字体属性
查看>>
学习设计模式——观察者模式
查看>>
什么是centos 的epel源
查看>>