【题目】

你的信用卡目前欠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. POJ3185 The Water Bowls(反转法or dfs 爆搜)

    POJ3185 The Water Bowls 题目大意: 奶牛有20只碗摆成一排,用鼻子顶某只碗的话,包括左右两只在内的一共三只碗会反向,现在给出碗的初始状态,问至少要用鼻子顶多少次才能使所有碗都朝 ...

  2. poj3620

    #include<iostream>#include<string>#include<stack>#include<vector>#include< ...

  3. linux文件系统结构和权限

    linux文件系统的目录结构 熟话说的好,好记性不如烂笔头,虽然没用笔,但动动手指还是可以的.下面的目录结构都是摘抄过来的,动动手指来加深下印象吧,还能练习下打字速度,哈哈,多好啊. ...突然又改变 ...

  4. 实用iPhone Cydia插件

      BadgeClear(角标清除):可以清除App推送所在图标右上角出现的红色角标.在桌面长按图标后,图标开始左右摇动,再双击图标即可清除点击的图标角标.   Bitesms(短信):收费插件,具有 ...

  5. fedora 安装nginx+php+mysql

    环境 fedora 最新版 20 参考:http://www.cnblogs.com/beceo/archive/2012/08/21/2648378.html ------------------- ...

  6. django 序列化json问题

    from django.core import serializers @login_required def ajax_get_data(request): json_data = serializ ...

  7. SpEL快速入门

    Spring表达式语言(简称SpEL)是一种鱼JSP2 EL功能类似的变道时语言,它可以在运行时查询和操作对象图.与JSP 2的EL相比,SpEL功能更加强大,它甚至支持方法的调用和基本字符串模板. ...

  8. 转:Node.js异步处理CPU密集型任务的新思路

    原文来自于:http://www.infoq.com/cn/articles/new-idea-of-nodejs-asynchronous-processing-tasks?utm_source=i ...

  9. poj 2031Building a Space Station

    http://poj.org/problem?id=2031 #include<cstdio> #include<cstring> #include<cmath> ...

  10. org.quartz.utils.UpdateChecker Checking for available updated version of Quartz..

    <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</ ...