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 ...
随机推荐
- HTML介绍和标签
1.HTML介绍 1.概述 html不是一种编程语言,是一种描述性的标记语言,用于描述超文本内容的显示方式.比如字体,颜色,大小等. 超文本:音频,视频,图片称为超文本. 标记:<英文单词或者字 ...
- [译]为任意网格计算tangent空间的基向量
+BIT祝威+悄悄在此留下版了个权的信息说: [译]为任意网格计算tangent空间的基向量 Computing Tangent Space Basis Vectors for an Arbitrar ...
- java练习---8
//程序员:罗元昊 2017.10.16 题目3.7 import java.util.Scanner; public class L { @SuppressWarnings("resour ...
- Java基础之分支结构循环结构
流程控制语句if(分支结构) 流程控制:流程就是指代码运行过程.控制就是说什么场景可以执行,什么场景不能执行. 1.if语句第一种形式 格式:if(表达式){ 执行的语句: } 2. ...
- JS制作简易的考试答题管理系统
答题卡系统: 网站运行效果 代码区域: HTML 代码: <style type="text/css"> body { font-size: 30px; backgro ...
- AbstractCollection
概述 这个类提供了实现Collection接口的骨架,来最小化实现此接口所做的工作. 要实现一个不可修改的 collection,编程人员只需扩展此类,并提供 iterator 和 size 方法的实 ...
- 极简代码神器:Lombok使用教程
Lombok 是一个非常神奇的 java 类库,会利用注解自动生成 java Bean 中烦人的 Getter.Setter,还能自动生成 logger.ToString.HashCode.Build ...
- Linux系统管理----账号与权限管理作业习题
1.创建/guanli 目录,在/guanli下创建zonghe 和 jishu 两个目录(一条命令) 创建目录:mkdir +目录 [root@localhost chen]#mkdir /guan ...
- 【Mac】Mac 使用 zsh 后, mvn 命令无效
如题-- 解决方法: 将 maven 的环境变量配置放到 .zshrc 文件中. 参考链接: http://ruby-china.org/topics/23158 https://yq.aliyun. ...
- poj 1131 Octal Fractions(高精度小数进制转换) Java
虽然题目那么长其实就是把8进制的浮点数转换成10进制,为了练习Java Biginteger 类 我这里用的是Java,也可以用数组模拟. import java.math.BigDecimal; i ...