• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codechef Code Crunch 2013 ATM

 

ATM

Problem code: MRIU11

 

  • Submit
  • All Submissions
 

Problem description.

Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US.
Calculate Pooja's account balance after an attempted transaction.

Input

Input description.

Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw.

Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja's initial account balance.

Output

Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance.

Example - Successful Transaction

Input:
30 120.00

Output: 89.50

Example - Incorrect Withdrawal Amount (not multiple of 5)

Input:
42 120.00

Output: 120.00

Example - Insufficient Funds

Input:
300 120.00

Output: 120.00
 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <queue>
 4 #include <vector>
 5 #include <string>
 6 #include <cstdio>
 7 #include <cstring>
 8 #include <iostream>
 9 #include <algorithm>
10 using namespace std;
11 #define maxn 10005
12 #define mod 1000000007
13 #define ll long long
14 #define INF 0x7fffffff
15 int n;
16 double m;
17 char s[maxn];
18 int main(){
19     int cas = 1;
20     int t;
21     /*scanf("%d", &t);
22     while (t--){
23         scanf("%d", &n);
24         printf("%I64d\n", f[n]);
25     }*/
26     while (~scanf("%d%lf", &n,&m)){
27         if (n % 5 == 0&&n>5)printf("%.2lf\n", m - n - 0.5);
28         else printf("%.2lf\n", m);
29     }
30     return 0;
31 }
View Code 2013-10-25 15:56:44
posted @ 2013-10-25 15:54  HaibaraAi  阅读(115)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3