poj 2390 Bank Interest(计算本利和)
一、Description
amount of money M in the range 100..1,000,000. He knows how many years Y (range: 0..400) he intends to invest the money in the bank. Help him learn how much money he will have in the future by compounding the interest for each year he saves. Print an integer
answer without rounding. Answers for the test data are guaranteed to fit into a signed 32 bit integer.
Input
Output
二、题解
题目的提示很明显,计算过程如下:
INPUT DETAILS:
5% annual interest, 5000 money, 4 years
OUTPUT DETAILS:
Year 1: 1.05 * 5000 = 5250
Year 2: 1.05 * 5250 = 5512.5
Year 3: 1.05 * 5512.50 = 5788.125
Year 4: 1.05 * 5788.125 = 6077.53125
The integer part of 6077.53125 is 6077.
需要注意的是计算过程中间结果要用double存放。
三、java代码
import java.util.Scanner; public class Main { public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int r,m,y,i;
double result,r1;
r=sc.nextInt();
m=sc.nextInt();
y=sc.nextInt();
r1=0.01 * r+1;
result=m;
for(i=0;i<y;i++){
result*=r1;
}
System.out.println((int)result);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
poj 2390 Bank Interest(计算本利和)的更多相关文章
- Bank Interest
Bank Interest Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Tota ...
- 1755: [Usaco2005 qua]Bank Interest
1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 187 Solved: 162[Su ...
- bzoj1755 [Usaco2005 qua]Bank Interest
Description Farmer John made a profit last year! He would like to invest it well but wonders how muc ...
- POJ 2398 - Toy Storage - [计算几何基础题][同POJ2318]
题目链接:http://poj.org/problem?id=2398 Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad ...
- POJ 2390
import java.util.*; public class Main { public static void main(String args[]){ double interest; Sca ...
- Jack Straws POJ - 1127 (几何计算)
Jack Straws Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5428 Accepted: 2461 Descr ...
- poj 3304 Segments(计算几何基础)
Segments Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11593 Accepted: 3657 Descr ...
- poj 1519 Digital Roots (计算根数字)
一.Description The digital root of a positive integer is found by summing the digits of the integer. ...
- Jack Straws POJ - 1127 (简单几何计算 + 并查集)
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...
随机推荐
- sgu 195 New Year Bonus Grant【简单贪心】
链接: http://acm.sgu.ru/problem.php?contest=0&problem=195 http://acm.hust.edu.cn/vjudge/contest/vi ...
- vue项目目录
项目目录说明 . |-- config // 项目开发环境配置 | |-- index.js // 项目 ...
- 4.对urls.py的解释
解释: 路由配置文件(URL分发器),它的本质是URL模式以及要为该URL模式调用的视图函数之间的映射表.就是以这种方式告诉Django对于每个URL的处理类.Django启动的时候回去加载urls. ...
- Django安装debug tool bar
1.安装Django Debug Toolbarpip install django-debug-toolbar 2.设置项目的DEBUG属性DEBUG = True 3.INSTALLED_APPS ...
- tomcat调试页面的时候,不刷新
1.调试一个页面的时候,js文件不刷新,也就是相当于没有改(cache) 2.解决:在Server中将当前tomcat的模式改为debug即可
- IBM db2安装好了以后,启动不了服务
系统默认将Server服务禁用,开启这个服务就可以启动服务.
- vs+opencv
vs + opencv 配置见网页 https://blog.csdn.net/qq_17550379/article/details/78201442 统一所有工程配置见下图:
- PHP eval函数使用介绍
eval()函数中的eval是evaluate的简称,这个函数的作用就是把一段字符串当作PHP语句来执行. 复制代码代码如下: eval("echo'hello world';") ...
- 【leetcode刷题笔记】Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- Android系统篇之—-编写简单的驱动程序并且将其编译到内核源码中【转】
本文转载自:大神 通过之前的一篇文章,我们了解了 Android中的Binder机制和远程服务调用 在这篇文章中主要介绍了Android中的应用在调用一些系统服务的时候的原理,那么接下来就继续来介绍一 ...