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 ...
随机推荐
- 通过sysbench工具实现MySQL数据库的性能测试
1.背景 sysbench是一款压力测试工具,可以测试系统的硬件性能,也可以用来对数据库进行基准测试.sysbench 支持的测试有CPU运算性能测试.内存分配及传输速度测试.磁盘IO性能测试.POS ...
- centOS7启动apache,报错Caused by: java.net.UnknownHostException: wshCentOS:
测试方法: ping 127.0.0.1 ping localhost 解决方案: vi /etc/hosts 把127.0.0.1和wshCentOS绑定就好 按 i 进入修改模式,按 esc 退出 ...
- 单调栈&单调队列
最近打了三场比赛疯狂碰到单调栈和单调队列的题目,第一,二两场每场各一个单调栈,第三场就碰到单调队列了.于是乎就查各种博客,找单调栈,单调队列的模板题去做,搞着搞着发现其实这两个其实是一回事,只不过利用 ...
- 0 Spark完成WordCount操作
先看下结果: pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http ...
- macvtap使用教程
kubernetes一键安装 macvtap是虚拟机网络虚拟化常用的一种技术,当然容器也可以用. MACVTAP 的实现基于传统的 MACVLAN. 和 TAP 设备一样,每一个 MACVTAP 设备 ...
- Mac OS 安装mysqlclient 遇到的坑~
最近在学习Python, 因为Django连接mysql 需要安装mysqlclient, 但Mac安装遇到各种问题,这里记录一下,避免以后再踩坑. 1. 正常情况下,安装mysqlclient ...
- JS中以一个方法作为参数的写法
一:以方法作为参数 这下来说直接以一个方法来作为参数的写法,直接上代码: -----------这样调用的方法------------- go(function(){ alert("succ ...
- TextView 使用详解
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- @Value注解 和 @Data注解
@Value注解 service层代码 @Service public class HelloServiceImpl implements HelloService { @Autowired priv ...
- .xxx.sh脚本无法启动,原来都是特殊字符搞的鬼?
今天遇到个趣的问题,linux上springboot启动,连接达梦数据库报错. 解决思路: 1)是不是数据库本身有问题,客户端登录没问题. 2)排查是不是war包问题,本地连接数据库,没问题. 3)是 ...