当前位置:网站首页>电子协会 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博客_打表出省一
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类等
边栏推荐
- Selection (021) - what is the output of the following code?
- Lottery system test report
- 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
- tars源码分析之2
- 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
- Four sets of APIs for queues
- Mysql 45讲学习笔记(十四)count(*)
- Selenium driver ie common problem solving message: currently focused window has been closed
- How does the inner roll break?
猜你喜欢

The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native

Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc

Mobile adaptation: vw/vh

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

The final week, I split

What is industrial computer encryption and how to do it
![[Valentine's day] - you can change your love and write down your lover's name](/img/ab/402872ad39f9dc58fd27dd6fc823ef.jpg)
[Valentine's day] - you can change your love and write down your lover's name

MySQL 45 lecture learning notes (VII) line lock

移动适配:vw/vh

Can the out of sequence message complete TCP three handshakes
随机推荐
CORS is not intended to protect API endpoints - nikofischer
[FPGA tutorial case 7] design and implementation of counter based on Verilog
颈椎、脚气
tars源码分析之10
用于压缩视频感知增强的多目标网络自适应时空融合
Introduction to spark core components
MySQL 45 lecture learning notes (XIV) count (*)
Vulhub vulnerability recurrence 77_ zabbix
tars源码分析之7
kubernetes集群之Label管理
tars源码分析之1
Download address of the official website of national economic industry classification gb/t 4754-2017
Tar source code analysis 6
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
List of top ten professional skills required for data science work
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture
Latex中的单引号,双引号如何输入?
Check and display one column in the known table column
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same