【题目】

你的信用卡目前欠M元,每月的汇率是R,每月的利息要四舍五入为小数点后两位,你每月还B元,问多少月能还清。

输入

先是T代表测试数据组数

接下来T行,每行有三个实数,R,M,B每个实数小数点后有两位

输出

每组测试数据输出一行,还清债务的最小月数,如果超过1200月都不能还清,输出“impossible”

【吐槽】

这道题过的好不容易,首先是读题,如果不了解那些银行业的词汇真读不懂题

比如interesting(利息),the outstanding balance(未付清的余额),payment(题目的意思应该是还款还多少月)。最难懂得是那个四舍五入:rounding up 0.5 cent and above,意思是0.5~1分向上取整。因为没有读懂最后那个,WA了无数次。。捂脸

【题解】

题目明确了还是很好算的,只需while一直循环就好了,只需注意一点,也是很多同学一直过不去的,就是浮点误差,0.005要约为0.01,但因为浮点误差所以有时候是0.00499999这时候也需要约为0.01,而不是0.00

【代码】

RunID

User

Problem

Result

Memory

Time

Language

Length

Submit Time

2549916

zhyfzy

E

Accepted

0 KB

33 ms

C++ 4.5.3

707 B

2014-07-31 16:36:07

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#define eps 0.000001//规定浮点误差范围,一般取这个数就可以了
using namespace std;
int i,j,k,n,x,y,T,ans;
double r,m,b;
double rou(double t)
{
double x=t*100;
double y=round(x);
if (fabs(x-y)<eps) return t;
x=(int)(x+0.5+eps);
x=x/100;
return x;
}
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%lf%lf%lf",&r,&m,&b);
ans=0;
while (m>eps)
{
ans++;
if (ans>1200) break;
m=m+rou(r*m*0.01);
m-=b;
}
if (ans>1200) printf("impossible\n");
else printf("%d\n",ans);
} }

LA 6448 Credit Card Payment的更多相关文章

  1. codeforces 893D Credit Card 贪心 思维

    codeforces 893D Credit Card 题目大意: 有一张信用卡可以使用,每天白天都可以去给卡充钱.到了晚上,进入银行对卡的操作时间,操作有三种: 1.\(a_i>0\) 银行会 ...

  2. Real Time Credit Card Fraud Detection with Apache Spark and Event Streaming

    https://mapr.com/blog/real-time-credit-card-fraud-detection-apache-spark-and-event-streaming/ Editor ...

  3. (原创)北美信用卡(Credit Card)个人使用心得与总结(个人理财版) [精华]

    http://forum.chasedream.com/thread-766972-1-1.html 本人2010年 8月F1 二度来美,现在credit score 在724-728之间浮动,最高的 ...

  4. Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card

    D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. magento 开启 3D secure credit card validation

    因为国外盗刷严重,于是得开启验证. 首先可以去 https://developer.cardinalcommerce.com/try-it-now.shtml.这上面有测试账号,截图如下:

  6. [Angular] Using directive to create a simple Credit card validator

    We will use 'HostListener' and 'HostBinding' to accomplish the task. The HTML: <label> Credit ...

  7. 网页报警提示 This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see https://goo.gl/zmWq3m.

    This page includes a password or credit card input in a non-secure context. A warning has been added ...

  8. Educational Codeforces Round 33 D. Credit Card

    Credit Card time limit per test2 seconds memory limit per test256 megabytes Recenlty Luba got a cred ...

  9. Computop支付网关(一) credit Card

    1.界面没有中文,只能选择英文 sp – Spanish; en – English; ca – Catalan; fr – French; de – German; du – Dutch; it – ...

随机推荐

  1. java学习——网络编程UDP

    UDP 将数据及源和目的封装成数据包中,不需要建立连接 每个数据报的大小限制在64k内 因无连接,是不可靠协议 不需要建立连接,速度快 TCP 建立连接,形成传输数据的通道 在连接中进行大数据量传输 ...

  2. (转)C++静态库与动态库

    本文出自 http://www.cnblogs.com/skynet/p/3372855.html 吴秦 什么是库 库是写好的现有的,成熟的,可以复用的代码.现实中每个程序都要依赖很多基础的底层库,不 ...

  3. Python标准库--os模块

    这个模块包含普遍的操作系统功能.如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的.即它允许一个程序在编写后不需要任何改动,也不会发生任何问题,就可以在Linux和Windows下运行.一个例 ...

  4. groovy构建和解析xml文件

    原文链接:http://www.ibm.com/developerworks/cn/java/j-pg05199/ 代码示例: 构建xml文件: def static createXmlFile(){ ...

  5. jQuery获取JSON格式数据方法

    getJSON方法: jQuery.getJSON(url,data,success(data,status,xhr)) $("button").click(function(){ ...

  6. 省队集训day6 B

    一道AC自动机题···· 一定要把一个节点没有的儿子接到它fai的儿子,否则会卡到n^2的······· #include<cstdio> #include<iostream> ...

  7. springmvc参数类型转换三种方式

    SpringMVC绑定参数之类型转换有三种方式:     1. 实体类中加日期格式化注解      @DateTimeFormat(pattern="yyyy-MM-dd hh:MM&quo ...

  8. Oulipo

    poj3461:http://poj.org/problem?id=3461 题意:求一个串在另一个串中出现的次数. 题解:直接套用KMP即可,在统计的时候做一下修改.找到之后不是直接返回,而是移动i ...

  9. Web分析日志

    http://www.docin.com/p-649515490.html http://wenku.baidu.com/link?url=kB-83fbl1Zc3Y6U2BYLj-lKMWShe8Z ...

  10. Extjs4 中在指定光标处插入值

    var rulearea = Ext.getCmp(文本域Id); var rulevalue = rulearea.getValue();// 获取文本textarea 里面的值 var start ...