开发者

CodeChef #3, Easy, Keep getting wrong answer

This is the problem I'm working on: http://www.codechef.com/problems/HS08TEST/

And this is my solution:

#include <stdio.h>

int main (void) {
        int withdraw_i;
        float balance_i;

        scanf("%d %f", &withdraw_i, &balance_i);

        if(withdraw_i % 5 == 0) {
                if(withdraw_i <= balance_i) {
                        float result = balance_i - withdraw_i - 0.5;
                        printf("%.2f", result);
                开发者_Python百科}
                else {
                        printf("%.2f", balance_i);
                }
        }
        else {
                printf("%.2f", balance_i);
        }
        return 0;
}

(In C) It works perfectly for the tests shown on the page, but, when I submit it, I still keep getting the error "wrong answer", what's going on?


It's because you didn't implement the conditions on this test correctly. Try the case "300 300".


It should be

if(withdraw_i+0.5 <= balance_i)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜