【题目】

你的信用卡目前欠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. linux之umask函数解析

    [lingyun@localhost umask_1]$ vim umask.c  + umask.c                                                 ...

  2. Linux系统配置成简单的路由器

    一.两个不同网段的子网相互访问或通信 废话不多说了,直接上图,一目了然吧. 按照如图配置,就可以实现两个不同网段的子网相互通信. 二.连接上网的配置: 如果想让这两个子网,不仅可以相互通信,而且还可以 ...

  3. Google Calendar(日历)设置农历生日提醒

    Generate birthday dates base on lunar birthdays for google calendar import Can be used for notifying ...

  4. 常用排序算法总结(C#版)

    首先,说说几个排序中的概念. 1.稳定排序和非稳定排序  简单地说就是所有相等的数经过某种排序方法后,仍能保持它们在排序之前的相对次序,我们就说这种排序方法是稳定的.反之,就是非稳定的. 比如:一组数 ...

  5. DeDe友情链接

    图片 {dede:flink row="} [field:link /] {/dede:flink} 文字 {dede:flink row="} [field:link /] {/ ...

  6. 安装mysql-python报错

    运行: pip install mysql-python报错如下: Downloading/unpacking MYSQL-python Downloading MySQL-python-1.2.5. ...

  7. easyui tabs 真正刷新用法

    //刷新当前标签Tabs function RefreshTab(currentTab) { var url = $(currentTab.panel('options')).attr('href') ...

  8. codeforces 305E Playing with String

    刚开始你只有一个字符串每次能选择一个有的字符串s,找到i,满足s[i - 1] = s[i + 1],将其分裂成3 个字符串s[1 ··  i - 1]; s[i]; s[i + 1 ·· |s|] ...

  9. laravel框架——composer导入laravel

    第一种: composer create-project --prefer-dist laravel/laravel 名称 "5.2.*"第二种: composer global ...

  10. VIJOS P1543极值问题

    已知m.n为整数,且满足下列两个条件:① m.n∈1,2,…,K② (n^ 2-mn-m^2)^2=1编一程序,对给定K,求一组满足上述两个条件的m.n,并且使m^2+n^2的值最大.例如,若K=19 ...