这该怎么做?我有答案,但有一些测试用例,当我提交时失败并给出错误答案 [英] How to do this? I have got answers but some test case where failing and giving as wrong answer when I submit it

查看:82
本文介绍了这该怎么做?我有答案,但有一些测试用例,当我提交时失败并给出错误答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海绵宝宝和抽奖球



海绵宝宝正在泳池俱乐部等他最好的朋友帕特里克。

由于他厌倦了等待,他开始在泳池俱乐部内与Raffle Balls进行一场比赛。

有一个装有N个Raffle球的袋子。每个球上印有1到N的不同数字。所有数字都是不同的。海绵宝宝从袋子里取出了三个球并拿走了他们的总和。现在,海绵宝宝旨在计算总和不大于给定数量K(< = N)的概率。他特别应该以p / q的形式显示答案。 (当答案为0或1时除外)。

你能帮助海绵宝宝编写一个简化概率任务的程序吗?



输入格式:

输入由两个整数N和K组成(0 <= K <= N <= 10000)。



输出格式:

以p / q的形式输出结果(答案为0或1时除外)。

有关格式规范,请参阅示例输入和输出。



样本输入1:

5 6

样本输出1:

1/10



样本输入2:

5 7

样本输出2:

1/5



我尝试过:



Spongebob Squarepants and Raffle Balls

Spongebob Squarepants was waiting at the Pool Club for his best friend Patrick.
As he got so bored of waiting, he set off for a game with Raffle Balls available inside the Pool Club.
There was a bag filled with N Raffle balls. Each Ball has a distinct number from 1 to N printed on it. All the numbers are distinct. Spongebob withdrew three balls from the bag and took their sum. Now Spongebob aimed to calculate the probability that the sum is not greater than the given number K(<=N). He was particular that the answer should be displayed in the form of p/q. (except when the answer is 0 or 1).
Can you help Spongebob in writing a program that eases the task of finding the probability?

Input Format :
Input consists of two integers, N and K. (0<=K<=N<=10000).

Output Format :
Output the result in the form of p/q (Except when the answer is 0 or 1).
Refer sample input and output for formatting specifications.

Sample Input 1:
5 6
Sample Output 1:
1/10

Sample Input 2:
5 7
Sample Output 2:
1/5

What I have tried:

main()
{
 int n,k,b,c,d;
scanf("%d%d",&n,&k);
c=n+k;
b=c-10;
d=c-10;
printf("%d%d",b,d);
return 0;
}

推荐答案

Quote:

我有答案,但有一些测试用例,当我提交时失败并给出错误答案

I have got answers but some test case where failing and giving as wrong answer when I submit it

main()
{
int n,k,b,c,d;
scanf("%d%d",&n,&k);
c=n+k;
b=c-10;
d=c-10;
printf("%d%d",b,d);
return 0;
} 



否:这个程序无法得到正确的答案,因为它根本不会尝试处理这个问题。 />


由于问题来自挑战网站,所有的兴趣都是你自己解决问题。



建议:拿一张纸,一支铅笔,每手10个球,用手解决问题。看看事情是如何运作的,就是算法。


No: this program can't get some correct answers because it don't try to handle the problem at all.

Since the problem comes from a challenge site, all the interest is that you solve the problem by yourself.

Advice: Take a sheet of paper, a pencil and solve the problem by hand for every sum with 10 balls. And see how things works, it is the algorithm.


这篇关于这该怎么做?我有答案,但有一些测试用例,当我提交时失败并给出错误答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆