LA 6448 Credit Card Payment
【题目】
你的信用卡目前欠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 |
Accepted |
0 KB |
33 ms |
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的更多相关文章
- codeforces 893D Credit Card 贪心 思维
codeforces 893D Credit Card 题目大意: 有一张信用卡可以使用,每天白天都可以去给卡充钱.到了晚上,进入银行对卡的操作时间,操作有三种: 1.\(a_i>0\) 银行会 ...
- 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 ...
- (原创)北美信用卡(Credit Card)个人使用心得与总结(个人理财版) [精华]
http://forum.chasedream.com/thread-766972-1-1.html 本人2010年 8月F1 二度来美,现在credit score 在724-728之间浮动,最高的 ...
- 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 ...
- magento 开启 3D secure credit card validation
因为国外盗刷严重,于是得开启验证. 首先可以去 https://developer.cardinalcommerce.com/try-it-now.shtml.这上面有测试账号,截图如下:
- [Angular] Using directive to create a simple Credit card validator
We will use 'HostListener' and 'HostBinding' to accomplish the task. The HTML: <label> Credit ...
- 网页报警提示 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 ...
- Educational Codeforces Round 33 D. Credit Card
Credit Card time limit per test2 seconds memory limit per test256 megabytes Recenlty Luba got a cred ...
- Computop支付网关(一) credit Card
1.界面没有中文,只能选择英文 sp – Spanish; en – English; ca – Catalan; fr – French; de – German; du – Dutch; it – ...
随机推荐
- AfxMessageBox("这里为提示框的内容");程序弹出一个提示窗口,可以做调试提示信息
AfxMessageBox("这里为提示框的内容"); 同时AfxMessageBox(AFX_IDP_PARSE_INT);里面也可以系统宏定义的一些参数
- Android单位度量
px(像素):屏幕上的点. in(英寸):长度单位.mm(毫米):长度单位.pt(磅):1/72英寸.dp(与密度无关的像素):一种基于屏幕密度的抽象单位.在每英寸160点的显示器上,1dp = 1p ...
- ext之关键字mixins、statics、require
1.mixins 说明:类似于面向对象中的多继承 <script type="text/javascript"> Ext.onReady(function () { / ...
- [OSGI]Eclipse4.2 OSGI依赖Bundle
Eclipse 4.2 OSGI 依赖的Bundle: org.eclipse.osgiorg.apache.felix.gogo.runtimeorg.apache.felix.gogo.comma ...
- CSU 1160(进制问题)
CSU 1160 Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%lld & %llu Descrip ...
- ADO.Net增、删、改、查
数据访问 需要引用 对应命名空间:System.Data.SqlClient; SqlConnection:连接对象 SqlCommand:命令对象 SqlDataReader:读取器对象 Comma ...
- ecilipse Javadoc文档注释
— 标签 @param @param 空格后面跟上形参(不是数据类型)空格后跟着对该参数的描述. 在描述中第一个名字为该变量的数据类型 对于参数的描述是一个句子,最好不要首字母大写, 如果出现了句号这 ...
- 转:Java开发牛人十大必备网站
原文来自于:http://www.importnew.com/7980.html 以下是我收集的Java开发牛人必备的网站.这些网站可以提供信息,以及一些很棒的讲座, 还能解答一般问题.面试问题等.质 ...
- 台积电16nm工艺为什么好过三星14nm
最近,关于iPhone6s A9处理器版本的事情的话题很热,最后都闹到苹果不得不出来解释的地步,先不评判苹果一再强调的整机综合续航差2~3%的准确性,但是三星14nm工艺相比台积电16nm工艺较差已经 ...
- 利用Keil u4调试,精确实现软件延时
用定时器延时,有时候显得有点麻烦,我们不如考虑软件精确延时,软件延时无非就是利用for或while多重循环.以前用到延时函数时,都是从网上下载别人写好的延时子程序.延时5ms,400ms,1s,……, ...