题意略。

思路:二分。注意当利率高且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的更多相关文章

  1. 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 ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. python函数基础-参数-返回值-注释-01

    什么是函数 函数就是有特定功能的工具 # python中有内置函数(python解释器预先封装好的)与自定义函数(用户自定义封装的)之分 为什么要用函数 # 可以减少代码冗余,增加代码复用性 # 使代 ...

  2. java一个类 继承HttpServlet 和实现Servlet区别

    java一个类 继承HttpServlet 和实现Servlet区别 servlet 是一个接口,如果实现这个接口,那么就必须实现接口里面定义的所有方法 而HttpServlet实现了servlet接 ...

  3. js,ts操作dom总结

    以上面为例: js获取placeholder节点 : document.getElementsByClassName("newTicket")[0].getAttributeNod ...

  4. Java集合Collention

    集合:又被称为容器,用来存储数据,他是一个对象,能够将具有相同性质的多个元素汇聚成一个整体,集合被用于存储,获取,操纵和传输聚合的数据. 这种数据结构称为集合 Collenction:他是集合的根接口 ...

  5. React入门理解demo

    1.React文档结构 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...

  6. 【iOS】UIImageView 点击事件

    UIImageView 并不像 UIButton 那样点击鼠标就可以关联点击事件,也不像 Android 里有 onClickListener,这个时候就需要借助 UITapGestureRecogn ...

  7. 【iOS】代码片段库

    若在某个 Objective-C 的实现文件中输入 init,Xcode 会自动列出一系列备选项,如图所示: Xcode 自动加入的这段代码源自代码片段库(code snippet library), ...

  8. 【Android Studio】常用快捷键

    1. 删除一行:Ctrl + X 更新中……

  9. EasyUI combobox下拉列表实现搜索过滤(模糊匹配)

    项目中的某个下拉列表长达200多个项,这么巨大的数量一个一个找眼镜都得看花,于是就得整了个搜索功能.看网上别人帖子有只能前缀匹配的方案,但只能前缀匹配的话用起来也不是很方便.于是就记录一下模糊匹配的方 ...

  10. dubbo是如何控制并发数和限流的?

    ExecuteLimitFilter ExecuteLimitFilter ,在服务提供者,通过 的 "executes" 统一配置项开启: 表示每服务的每方法最大可并行执行请求数 ...