当前位置:网站首页>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
边栏推荐
- MySQL 45 lecture learning notes (VII) line lock
- thread priority
- The difference between synchronized and lock
- Fundamentals of SQL database operation
- ABCD four sequential execution methods, extended application
- tars源码分析之9
- What is the use of cloud redis? How to use cloud redis?
- Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
- Cochez une colonne d'affichage dans une colonne de tableau connue
- Wechat applet scroll view component scrollable view area
猜你喜欢
响应式——媒体查询
关于IDEA如何设置快捷键集
selenium IDE插件下载安装使用教程
Introduction to spark core components
Fundamentals of SQL database operation
notepad++如何统计单词数量
Google Chrome Portable Google Chrome browser portable version official website download method
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
The final week, I split
响应式移动Web测试题
随机推荐
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
Lottery system test report
[number theory] fast power (Euler power)
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
Analysis of tars source code 1
The important role of host reinforcement concept in medical industry
在已經知道錶格列勾選一個顯示一列
tcp socket 的 recv 如何接收指定长度消息?
Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
Wechat applet scroll view component scrollable view area
《剑指Offer》第2版——力扣刷题
Deep profile data leakage prevention scheme
Vulhub vulnerability recurrence 77_ zabbix
The final week, I split
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
Mysql 45讲学习笔记(七)行锁
[MySQL transaction]
Fundamentals of SQL database operation
Mysql 45讲学习笔记(十四)count(*)
Tar source code analysis 4