当前位置:网站首页>电子协会 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博客_打表出省一
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类等
边栏推荐
- Design of test cases
- About how idea sets up shortcut key sets
- P26-P34 third_ template
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- 2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
- tcp socket 的 recv 如何接收指定长度消息?
- tars源码分析之3
- 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?
- How notepad++ counts words
- leetcode825. Age appropriate friends
猜你喜欢

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

颈椎、脚气

MySQL 45 lecture learning notes (VII) line lock

【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)

Selenium driver ie common problem solving message: currently focused window has been closed

Fundamentals of SQL database operation

Campus network problems

【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA

Flink memory model, network buffer, memory tuning, troubleshooting
随机推荐
移动适配:vw/vh
《剑指Offer》第2版——力扣刷题
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Industrial computer anti-virus
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
云Redis 有什么用? 云redis怎么用?
MySQL 45 lecture learning notes (XIV) count (*)
NLP-文献阅读总结
leetcode825. 适龄的朋友
Download address of the official website of national economic industry classification gb/t 4754-2017
[number theory] fast power (Euler power)
Can the out of sequence message complete TCP three handshakes
MySQL 45 lecture learning notes (VI) global lock
Responsive - media query
P26-P34 third_ template
Fundamentals of SQL database operation
leetcode 310. Minimum Height Trees
在已經知道錶格列勾選一個顯示一列
What is the sheji principle?
Google Chrome Portable Google Chrome browser portable version official website download method