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 ...
随机推荐
- Mac下nginx安装和配置
nginx安装 brew search nginx brew install nginx 安装完以后,可以在终端输出的信息里看到一些配置路径: /usr/local/etc/nginx/nginx.c ...
- IBM db2安装好了以后,启动不了服务
系统默认将Server服务禁用,开启这个服务就可以启动服务.
- Spring Cloud之搭建动态Zuul网关路由转发
传统方式将路由规则配置在配置文件中,如果路由规则发生了改变,需要重启服务器.这时候我们结合上节课内容整合SpringCloud Config分布式配置中心,实现动态路由规则. 将yml的内容粘贴到码云 ...
- sqlite3简单教程整理
一.Ubuntu下安装sqlite3 1.介绍:sqlite3是linux上的小巧的数据库,一个文件就是一个数据库. 2.安装: 要安装sqlite3,可以在终端提示符后运行下列命令: sud ...
- 表达式语句(EL)
EL的基本语法 ${expression} Expression:制定要输出的变了或字符串.或EL运算符组成的表达式. 禁用EL表达式: 1. 使用“\”符号禁用. \${expression} 2. ...
- OTSU大津法对图像二值化
OTSU算法 (1)原理: 对于图像I(x,y),前景(即目标)和背景的分割阈值记作T,属于背景的像素个数占整幅图像的比例记为ω0,其平均灰度μ0:前景像素个数占整幅图像的比例为ω1,其平均灰度为μ1 ...
- php数组转换成js可用的数组的两种方式
1.如果你理解JSON数据格式的话,这个问题就异常简单: <?php $a =array('1','2','3'); ?> <script language="javasc ...
- win2008server R2 x64 部署.net core到IIS
1.下载sdk 和.NET Core Windows Server Hosting https://www.microsoft.com/net/download 2.出现HTTP 错误 500. ...
- 分享知识-快乐自己:Linux下安装 erlang 及 RabbitmMQ
Linux下安装 erlang 及 RabbitmMQ: 下载地址一 下载地址二 下载地址三 安装依赖: yum install ncurses-devel 安装 erlang: 1):下载Erla ...
- codeforces 615E Hexagons (二分+找规律)
E. Hexagons time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...