当前位置:网站首页>电子协会 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博客_打表出省一
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类等
边栏推荐
- tars源码分析之3
- The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
- leetcode825. Age appropriate friends
- Since DMS is upgraded to a new version, my previous SQL is in the old version of DMS. In this case, how can I retrieve my previous SQL?
- com. alibaba. nacos. api. exception. NacosException
- Mysql 45讲学习笔记(十)force index
- 2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
- MySQL 45 lecture learning notes (VII) line lock
- 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?
- Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
猜你喜欢

Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture

Google Chrome Portable Google Chrome browser portable version official website download method

selenium驱动IE常见问题解决Message: Currently focused window has been closed.

Deep profile data leakage prevention scheme

Knowledge payment applet dream vending machine V2

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

The final week, I split

期末周,我裂开

颈椎、脚气

BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
随机推荐
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
regular expression
What is the "relative dilemma" in cognitive fallacy?
Cochez une colonne d'affichage dans une colonne de tableau connue
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
云Redis 有什么用? 云redis怎么用?
抽奖系统测试报告
The most effective futures trend strategy: futures reverse merchandising
MySQL 45 lecture learning notes (x) force index
tars源码分析之10
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
leetcode 310. Minimum Height Trees
响应式移动Web测试题
tars源码分析之6
Summary of June 2022
Selenium ide plug-in download, installation and use tutorial
Can the out of sequence message complete TCP three handshakes
Responsive - media query
selenium IDE插件下载安装使用教程
tars源码分析之8