【题目】

你的信用卡目前欠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. 【COGS495】窗口

    [问题描述] 给你一个长度为N的数组,一个长为K的滑动的窗体从最左移至最右端,你只能见到窗口的K个数,每次窗体向右移动一位,如下表: Window position Min value Max val ...

  2. java获得url里面所带参数的值

    url: http://localhost:8080/test/list?p=1&d=2014 要获得所带参数p和d的值,方法如下: int p = Integer.parseInt(requ ...

  3. linux 配置 sphinx 全文搜索引擎

    因为公司网站需要,最近在弄sphinx搜索引擎,也是遇到各种问题,最终终于解决了. 服务器系统:centos7 (64位) 详情看安装官网的安装教程进行 coreseek 3.2.14 这里只提一些注 ...

  4. python3数据类型--数字

    数字 Python数字数据类型用于存储数值.数字数据类型是不允许改变的,所以如果改变数字数据类型的值,将重新分配内存空间. 以下实例在变量赋值时Number对象被创建: #!/usr/bin/env ...

  5. Cmakelist.txt

    在LINUX下面编程需要注意的是,需要自己配置链接库,比如 TARGET_LINK_LIBRARIES(),需要把自己要加的库加进去

  6. Oracle游标、参数的使用例子

    /// <summary> /// 总部审核 /// </summary> /// <param name="ht"></param> ...

  7. map 和 reduce

    注意:reduce需要 from functools import reduce map的使用: >>> def func(x): ... return x*x ... >&g ...

  8. JVM笔记-逃逸分析

    参考: http://www.iteye.com/topic/473355http://blog.sina.com.cn/s/blog_4b6047bc01000avq.html 什么是逃逸分析(Es ...

  9. swift material

    import UIKit extension UIColor { convenience init(hex:Int, alpha:CGFloat=1.0) { let red = CGFloat((h ...

  10. POJ 2774 最长公共子串

    一定好好学SAM...模板在此: #include<iostream> #include<cstdio> #include<cmath> #include<a ...