当前位置:网站首页>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
边栏推荐
- Vulhub vulnerability recurrence 77_ zabbix
- Tar source code analysis 9
- Flink memory model, network buffer, memory tuning, troubleshooting
- 在已經知道錶格列勾選一個顯示一列
- Latex中的单引号,双引号如何输入?
- How notepad++ counts words
- Lottery system test report
- Google Chrome Portable Google Chrome browser portable version official website download method
- Design of test cases
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
猜你喜欢
关于IDEA如何设置快捷键集
Responsive - media query
Fundamentals of SQL database operation
Google Chrome Portable Google Chrome browser portable version official website download method
The final week, I split
What is industrial computer encryption and how to do it
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
随机推荐
Tar source code analysis 4
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
How does the recv of TCP socket receive messages of specified length?
Cervical vertebra, beriberi
Common usage of time library
[backpack DP] backpack problem
Selenium ide plug-in download, installation and use tutorial
NLP-文献阅读总结
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Status of the thread
在已經知道錶格列勾選一個顯示一列
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
What is a spotlight effect?
Set JTAG fuc invalid to normal IO port
2022年6月小结
How can the old version of commonly used SQL be migrated to the new version?
Design of test cases
在已经知道表格列勾选一个显示一列