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 ...
随机推荐
- output value . Sigmoid neurons are similar to perceptrons, but modified so that small changes in their weights and bias cause only a small change in their output.
http://neuralnetworksanddeeplearning.com/chap1.html . Sigmoid neurons are similar to perceptrons, bu ...
- 制作透明的图标ICO
1.使用crowldraw画图保存为PNG格式,选择"被遮盖区域",然后保存(保存为PNG的透明格式). 2.使用IconWorkshop把透明的PNG格式导出为ICO.
- php添加或升级扩展模块步骤
php添加或升级扩展模块步骤: 1).下载对应扩展的稳定版源码包2).进入到解压后的源码包执行: sudo /usr/local/php/bin/phpize //对应安装到哪个php版本 sudo ...
- Linux系统中UI库curse.h不存在问题——贪吃蛇为例
1. 问题 大家在用Linux写程序时,大家会使用Linux gcc编译器中的头文件curse.h.但往往一般的发行版中都没有默认安装这个头文件,需要大家自行安装.最近遇到这个问题,如下: Red ...
- 《DevExpress》记录之TreeList
如这两幅图所示:如果要显示左边的竖线,需要设置 感谢 DoomGuards本节Dome下载地址:http://pan.baidu.com/s/1wBOJk 密码:vz4d
- 【leetcode刷题笔记】Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题 ...
- Spring Cloud之网关搭建
统一由网关进行拦截判断 要不放到每个服务里面就很不合适了 冗余 主要的: <dependency> <groupId>org.springframework.cloud< ...
- java入门了解06
1.进程 : (一)正在执行的程序称作为一个进程. 进程负责了内存空间的划分. (二)问题: windows号称是多任务的操作系统,那么windows是同时运行多个应用程序吗? 从宏观的角度: ...
- 关于 tornado.simple_httpclient SimpleAsyncHTTPClient fetch下载大文件,默认60s的问题
遇到了线上发布任务失败的情况,要发布的包大小77M,网络OK,手动测试速度是1.7M,下载77M文件用时17s左右,理论上完全没有问题 但是,从日志看确实是download的时候,60s 超时了,而且 ...
- 大话设计模式--备忘录 Memento -- C++实现实例
1. 备忘录: 在不破坏封装性的前提下, 捕获一个对象的内部状态,并在该对象之外保存这个状态,这样以后可将该对象恢复到原先保存的状态. Originator 发起人: 负责创建一个备忘录Memento ...