Gym - 101252H
题意略。
思路:二分。注意当利率高且m比较小的时候,每个月的偿还可能会大于本金,所以我们二分的右边界应该要设为2 * 本金。
详见代码:
#include<bits/stdc++.h>
#define eps 1e-7
using namespace std; double s,p;
int m; int sgn(double x){
if(fabs(x) < ) return ;
if(x > ) return ;
else if(x < ) return -;
}
bool jud(double x){
double fir = x * m;
double ai = s * p,bi = x - ai;
double sum1 = ai,sum2 = bi;
for(int i = ;i <= m;++i){
ai = (s - sum2) * p;
bi = (x - ai);
sum1 += ai;
sum2 += bi;
}
return sgn(s - sum2) <= ;
} int main(){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
scanf("%lf%d%lf",&s,&m,&p);
double l = ,r = * s,mid;
p /= 100.0;
while(fabs(r - l) > eps){
mid = (r + l) / ;
if(jud(mid)) r = mid;
else l = mid;
}
printf("%lf\n",l);
return ;
} /*
100 1 50
*/
Gym - 101252H的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- c++语言常用转义序列符号
\a 响铃 \n 换行符 \r 回车符 t 水平制表符(Tab键) \b 退格符(BackSpace键) \\ 反斜线 \' ...
- chapter01
1.请用命令查出ifconfig命令程序的绝对路径[root@localhost ~]# which ifconfig 答:/usr/sbin/ifconfig 2.请用命令展示以下命令哪些是内部命令 ...
- Java核心技术(卷一)读书笔记——第二章(JAVA/JDK环境配置)
JDK 配置:自行百度. 存在多个JDK 版本并且需要指定某版本时,注意更改注册表JavaSoft项以及相关子项,同时删除system32目录下相关的Java可执行文件xxx.exe. IDEA打开项 ...
- 1A2B
玩了玩www.syscan.org的小游戏,第三关是一个1A2B的问题,写个小脚本爆破一波,同时分享下脚本(把数固定到代码里了,要在别处用的自己改吧). #-*-coding:utf8;-*- #qp ...
- 【iOS】Interface Builder 预览
Interface Builder 为最顶层视图提供了 Simulated Metrics,预览用户界面的各种外观设置效果,例如顶部有导航栏或底部有标签栏的效果,如图所示:
- HelloDjango 系列教程:第 04 篇:Django 迁移、操作数据库
文中涉及的示例代码,已同步更新到 HelloGitHub-Team 仓库 我们已经编写了博客数据库模型的代码,但那还只是 Python 代码而已,django 还没有把它翻译成数据库语言,因此实际上这 ...
- DesignPattern系列__01SingletonResponsibility
单一职责原则 单一职责原则:一个类应该只有一个原因引起改变,即一个类应该只负责一个业务逻辑. 问题由来:类T负责t1, t2两个职责,当因为t1j对类T修改的时候,可能导致类T出现问题而影响职责t2. ...
- 2月9日 《Java 8实战》读后感
第一部分 基础知识 第3章 Lambda表达式 使用函数式接口 Predicate Consumer Function 第二部分 函数式数据处理 第4章 引入流 第5章 使用流 第6章 用流收集数据 ...
- 线性分类 Linear Classification
软分类:y 的取值只有正负两个离散值,例如 {0, 1} 硬分类:y 是正负两类区间中的连续值,例如 [0, 1] 一.感知机 主要思想:分错的样本数越少越好 用指示函数统计分错的样本数作为损失函数, ...
- sql语句优化:尽量使用索引避免全表扫描
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...