当前位置:网站首页>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
边栏推荐
- Selection (023) - what are the three stages of event propagation?
- Google Chrome Portable Google Chrome browser portable version official website download method
- thread priority
- 《国民经济行业分类GB/T 4754—2017》官网下载地址
- 移动适配:vw/vh
- [GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
- What is Gibson's law?
- Can the out of sequence message complete TCP three handshakes
- What is industrial computer encryption and how to do it
猜你喜欢
Centos8 install mysql 7 unable to start up
Common usage of time library
电脑通过Putty远程连接树莓派
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
What is the use of cloud redis? How to use cloud redis?
Set JTAG fuc invalid to normal IO port
Industrial computer anti-virus
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
随机推荐
电脑通过Putty远程连接树莓派
Modify TCP timestamp to optimize transmission performance
Tar source code analysis Part 3
CORS is not intended to protect API endpoints - nikofischer
How does the recv of TCP socket receive messages of specified length?
Mobile adaptation: vw/vh
ABCD four sequential execution methods, extended application
js 常用时间处理函数
Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
Can the out of sequence message complete TCP three handshakes
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
内卷怎么破?
tars源码分析之6
MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
Tar source code analysis 9
[number theory] fast power (Euler power)
Finishing (III) - Exercise 2
tars源码分析之2
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘