当前位置:网站首页>Electronic Association C language level 1 35, bank interest
Electronic Association C language level 1 35, bank interest
2022-07-04 06:59:00 【dllglvzhenfeng】
Electronics Association C Language 1 level 35 、 Bank interest
OpenJudge - 2390: Bank interest
C++ Code Method 1
/*
Electronics Association C Language 1 level 35 、 Bank interest
http://noi.openjudge.cn/ch0105/15/
http://bailian.openjudge.cn/practice/2390/
Farmer John made a lot of money last year ! He wants to invest the money , And how much you can get
Yi is curious . The compound annual interest rate of the known investment is R(0 To 20 Integer between ). John's current total value is M Of
money (100 To 1,000,000 Integer between ). He clearly knows he wants to invest Y year ( Range 0 To 400).
Please help him calculate how much money he will have in the end , And output its integer part . The data guarantees that the output results are in 32 You have
Within the range of signed integers .
Input
A line contains three integers R,M,Y, Two adjacent integers are separated by a single space .
Output
An integer , That is, how much money John eventually has ( Integral part ).
The sample input
5 5000 4
Sample output
6077
Tips
In the example ,
After the first year : 1.05 * 5000 = 5250
Second years later : 1.05 * 5250 = 5512.5
After the third year : 1.05 * 5512.50 = 5788.125
After the fourth year : 1.05 * 5788.125 = 6077.53125
6077.53125 The integer part of is 6077.
source :USACO 2004 November
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,r,m,y;
double sum;
scanf("%d%d%d",&r,&m,&y);
sum=m;
for(i=1;i<=y;i++)
{
sum=sum*(1+0.01*r);
}
printf("%d",(int)sum);
return 0;
}
C++ Code Method 2
/*
1.5 Cycle control of programming basis _15 Bank interest Method 2
http://noi.openjudge.cn/ch0105/15/
*/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int R, M, Y;
double money;
cin >> R >> M >> Y;
money = M;
for (int i=0; i<Y; i++)
{
money *= (100+R)/100.0;
}
cout << (int)money << endl;
return 0;
}
C++ Code : Method 3
/*
1.5 Cycle control of programming basis _15 Bank interest Method 3
http://noi.openjudge.cn/ch0105/15/
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int R,Y;
long long M;
cin>>R>>M>>Y;
M=M*pow(1+R*0.01,Y);
cout<<M;
return 0;
}
python3 Code :
l = list(map(float, input().split()))
R = l[0];M = l[1];Y = l[2]
i = 1
money = M
while i <= Y:
i += 1
money *= 1 + R / 100
print(int(money))
#writen by XiaoMaFenJu
Baby's programming series
Baby's programming series _dllglvzhenfeng The blog of -CSDN Blog
Baby's Physics Series
Baby's Physics Series _dllglvzhenfeng The blog of -CSDN Blog
Baby's math books
Baby's math books _dllglvzhenfeng The blog of -CSDN Blog
《 Mathematics and life 》 Of 3 books
《 Mathematics and life 》 Of 3 books _dllglvzhenfeng The blog of -CSDN Blog
Math girl series
Math girl series _dllglvzhenfeng The blog of -CSDN Blog
Rationalism : Mathematics photo album series books, etc
Rationalism : Mathematics photo album series books, etc _dllglvzhenfeng The blog of -CSDN Blog
Recommend several introductory books on calculus
linear algebra 、 probability Introduction book recommendation
Introduction to combinatorics books
Introduction to combinatorics books _dllglvzhenfeng The blog of -CSDN Blog
Introduction to group theory
Introduction to group theory _dllglvzhenfeng The blog of -CSDN Blog _ Introduction to group theory
Combinatorial mathematics —— ***
Combinatorial mathematics —— *** _mumei314 The blog of -CSDN Blog
Rubik's cube and group theory
Rubik's cube and group theory _ Blog on the beauty of algorithms and Mathematics -CSDN Blog
Understanding Euler formula from the perspective of group theory
Mathematics in Xinao : stirling numbers 、 Carter LAN number
Mathematics in Xinao : stirling numbers 、 Carter LAN number _dllglvzhenfeng The blog of -CSDN Blog
Mathematics in Xinao : The generating function
Mathematics in Xinao : The generating function _dllglvzhenfeng The blog of -CSDN Blog
Mathematics in Xinao : Sun Tzu's Theorem Chinese remainder theorem
Mathematics in Xinao : Unique decomposition theorem
Mathematics in Xinao : Unique decomposition theorem _dllglvzhenfeng The blog of -CSDN Blog
In Xinao “ cheat ” Divine skill ---“ The meter ”
Mobius inversion Balanced planning Double stack deque Equivalence classes, etc
边栏推荐
- Google Chrome Portable Google Chrome browser portable version official website download method
- uniapp小程序分包
- Selection (021) - what is the output of the following code?
- MySQL 45 lecture learning notes (VII) line lock
- 2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
- Deep profile data leakage prevention scheme
- Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
- Novel website program source code that can be automatically collected
- What is the use of cloud redis? How to use cloud redis?
- tars源码分析之9
猜你喜欢
About how idea sets up shortcut key sets
Wechat applet scroll view component scrollable view area
List of top ten professional skills required for data science work
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
Responsive - media query
Uniapp applet subcontracting
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
随机推荐
tars源码分析之1
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
Data analysis notes 09
Mysql 45讲学习笔记(十)force index
[FPGA tutorial case 7] design and implementation of counter based on Verilog
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
Modify TCP timestamp to optimize transmission performance
Mysql 45讲学习笔记(七)行锁
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
tars源码分析之10
Check and display one column in the known table column
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Responsive mobile web test questions
Fundamentals of SQL database operation
Design of test cases
电脑通过Putty远程连接树莓派
How does the inner roll break?
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
MySQL 45 learning notes (XI) how to index string fields