当前位置:网站首页>电子协会 C语言 1级 35 、银行利息
电子协会 C语言 1级 35 、银行利息
2022-07-04 06:57:00 【dllglvzhenfeng】
电子协会 C语言 1级 35 、银行利息
C++代码 方法一
/*
电子协会 C语言 1级 35 、银行利息
http://noi.openjudge.cn/ch0105/15/
http://bailian.openjudge.cn/practice/2390/
农夫约翰在去年赚了一大笔钱!他想要把这些钱用于投资,并对自己能得到多少收
益感到好奇。已知投资的复合年利率为 R(0 到 20 之间的整数)。约翰现有总值为 M 的
钱(100 到 1,000,000 之间的整数)。他清楚地知道自己要投资 Y 年(范围 0 到 400)。
请帮助他计算最终他会有多少钱,并输出它的整数部分。数据保证输出结果在 32 位有
符号整数范围内。
输入
一行包含三个整数 R,M,Y,相邻两个整数之间用单个空格隔开。
输出
一个整数,即约翰最终拥有多少钱(整数部分)。
样例输入
5 5000 4
样例输出
6077
提示
在样例中,
第一年后: 1.05 * 5000 = 5250
第二年后: 1.05 * 5250 = 5512.5
第三年后: 1.05 * 5512.50 = 5788.125
第四年后: 1.05 * 5788.125 = 6077.53125
6077.53125 的整数部分为 6077。
来源: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++代码 方法二
/*
1.5编程基础之循环控制_15银行利息 方法二
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++代码:方法三
/*
1.5编程基础之循环控制_15银行利息 方法三
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代码:
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宝宝的编程系列书籍
宝宝的编程系列书籍_dllglvzhenfeng的博客-CSDN博客
宝宝的物理学系列
宝宝的物理学系列_dllglvzhenfeng的博客-CSDN博客
宝宝的数学书籍
宝宝的数学书籍_dllglvzhenfeng的博客-CSDN博客
《数学与生活》的3本书籍
《数学与生活》的3本书籍_dllglvzhenfeng的博客-CSDN博客
数学女孩系列书籍
数学女孩系列书籍_dllglvzhenfeng的博客-CSDN博客
理性派:数学写真集系列书籍等
理性派:数学写真集系列书籍等_dllglvzhenfeng的博客-CSDN博客
推荐几本微积分入门书籍
推荐几本微积分入门书籍_dllglvzhenfeng的博客-CSDN博客_微积分入门书籍
线性代数、概率 入门书籍推荐
线性代数、概率 入门书籍推荐_dllglvzhenfeng的博客-CSDN博客_线性代数书籍推荐
组合数学入门书籍推荐
组合数学入门书籍推荐_dllglvzhenfeng的博客-CSDN博客
群论入门书籍推荐
群论入门书籍推荐_dllglvzhenfeng的博客-CSDN博客_群论入门教材
组合数学——群论学习总结
组合数学——群论学习总结_mumei314的博客-CSDN博客
魔方和群论
从群论角度理解欧拉公式
从群论角度理解欧拉公式_MatheMagician的博客-CSDN博客
信奥中的数学:斯特林数、卡特兰数
信奥中的数学:斯特林数、卡特兰数_dllglvzhenfeng的博客-CSDN博客
信奥中的数学:母函数
信奥中的数学:母函数_dllglvzhenfeng的博客-CSDN博客
信奥中的数学:孙子定理 中国剩余定理
信奥中的数学:孙子定理 中国剩余定理_dllglvzhenfeng的博客-CSDN博客
信奥中的数学:唯一分解定理
信奥中的数学:唯一分解定理_dllglvzhenfeng的博客-CSDN博客
信奥中的“骗”分神技 ---“打表”
信奥中的“骗”分神技 ---“打表”_dllglvzhenfeng的博客-CSDN博客_打表出省一
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类等
边栏推荐
- regular expression
- Redis面试题集
- Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
- Vulhub vulnerability recurrence 77_ zabbix
- MySQL 45 lecture learning notes (VI) global lock
- 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
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- MySQL 45 lecture learning notes (XIV) count (*)
- 期末周,我裂开
- 同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
猜你喜欢

Centos8 install mysql 7 unable to start up

Another company raised the price of SAIC Roewe new energy products from March 1

颈椎、脚气

Fundamentals of SQL database operation

用于压缩视频感知增强的多目标网络自适应时空融合

How to share the source code anti disclosure scheme

GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式

regular expression
![[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)](/img/03/2b37e63d0d482d5020b7421ac974cb.jpg)
[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)

Crawler (III) crawling house prices in Tianjin
随机推荐
Selection (021) - what is the output of the following code?
tars源码分析之1
高薪程序员&面试题精讲系列119之Redis如何实现分布式锁?
关于IDEA如何设置快捷键集
leetcode 310. Minimum Height Trees
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Selection (022) - what is the output of the following code?
What is tweeman's law?
2022年6月小结
Summary of leetcode BFS question brushing
Vulhub vulnerability recurrence 77_ zabbix
Redis interview question set
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Tar source code analysis 6
regular expression
Deep profile data leakage prevention scheme
Summary of June 2022
电脑通过Putty远程连接树莓派
MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
CORS is not intended to protect API endpoints - nikofischer