HDUOJ------2398Savings Account
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
HDU “Valentines Day” Open Programming Contest 2009-02-14
水体:
代码:
1 #include<stdio.h>
2 #include<string.h>
3 #include<stdlib.h>
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("%dn",cnt);
17 cnt=0;
18 }
19 return 0;
20 }
- 初学HTML一些基本控件语句
- java学习之第五章编程题示例(初学篇)
- java第四章编程题(初学篇)
- java测试Unicode编码以及数组的运用(初学篇)
- HDUOJ---1754 Minimum Inversion Number (单点更新之求逆序数)
- HDUOJ-------1753大明A+B(大数之小数加法)
- HDUOJ---1754 I Hate It (线段树之单点更新查区间最大值)
- HDUOJ----1166敌兵布阵(线段树单点更新)
- poj----2155 Matrix(二维树状数组第二类)
- poj------2352 Stars(树状数组)
- HDUOJ-----2852 KiKi's K-Number(树状数组+二分)
- nyoj----522 Interval (简单树状数组)
- HDUOJ-----2838Cow Sorting(组合树状数组)
- HDUOJ---2642Stars(二维树状数组)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- linux/OSX中“DD”命令制作ISO镜像操作系统安装U盘的方法
- 《高效能程序员的修炼》读书笔记
- linux之centos7防火墙基本使用详解
- Ubuntu安装scrcpy完成手机投屏和控制(Ubuntu用QQ微信的另一种方法)
- CentOS7 systemd添加自定义系统服务的方法
- Linux中sudo、su和su -命令的区别小结
- 非零环绕规则
- Linux被中断的系统如何调用详解
- centos 修改ssh默认端口号的方法示例
- Linux中特殊权限SUID、SGID与SBIT的深入讲解
- linux新文件权限设置之umask的深入理解
- 在 CentOS 8/RHEL 8 上安装和使用 Cockpit的方法
- Linux删除文件提示Operation not permitted的处理办法
- 微任务与宏任务
- Linux 文件权限的详细介绍