当前位置:网站首页>电子协会 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博客_打表出省一
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类等
边栏推荐
- How does the inner roll break?
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
- 在已经知道表格列勾选一个显示一列
- If there are two sources in the same job, it will be reported that one of the databases cannot be found. Is there a boss to answer
- MySQL 45 lecture learning notes (12) MySQL will "shake" for a while
- Redis面试题集
- Software keywords and process information intercepted by Golden Shield video player
- 云Redis 有什么用? 云redis怎么用?
- 用于压缩视频感知增强的多目标网络自适应时空融合
- 2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
猜你喜欢
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Vulhub vulnerability recurrence 77_ zabbix
What is industrial computer encryption and how to do it
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
P26-P34 third_ template
响应式移动Web测试题
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
随机推荐
Background and current situation of domestic CDN acceleration
How can the old version of commonly used SQL be migrated to the new version?
2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
Tar source code analysis Part 10
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
Explain in one sentence what social proof is
What is the "relative dilemma" in cognitive fallacy?
P26-P34 third_ template
响应式移动Web测试题
测试用例的设计
电脑通过Putty远程连接树莓派
leetcode 310. Minimum Height Trees
在已经知道表格列勾选一个显示一列
What is the sheji principle?
Cervical vertebra, beriberi
List of top ten professional skills required for data science work
Check and display one column in the known table column
Flink memory model, network buffer, memory tuning, troubleshooting