530 - Binomial Showdown

All about problems in Volume 5. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

galiver_iran
New poster
Posts: 1
Joined: Thu Aug 12, 2010 7:25 am
Location: iran

Re: 530 Why WA

Post by galiver_iran » Mon Aug 16, 2010 6:41 am

variable is short.

vvsargentt5
New poster
Posts: 1
Joined: Mon Jun 27, 2011 6:29 am

Mexican Quesadillas Recipes

Post by vvsargentt5 » Thu Aug 04, 2011 3:33 pm

Bean Quesadillas

Bean Quesadillas Ingredients:

? 4 6-inch whole wheat or flavored flour tortillas

? 1/4 cup regular salsa or taco sauce

? 1 1/2 cups shredded cheddar blend, lightly packed

? 1/2 cup canned black or kidney beans, rinsed and drained

Bean Quesadillas Recipe Directions:

1. Preheat the oven to 250°F then place a baking pan.

2. Place the tortilla to the countertop of a waxed paper or paper towel.

3. Lightly pack a 1/3-cup dry measuring cup with cheese.

4. Pour half of the cheese over the bottom half of the tortilla, spread evenly to within 1/4 inch of the edge.

5. Take 1 tablespoon of salsa (or taco sauce) evenly over the cheese, then put 2 tablespoons of the beans evenly over the salsa.

6. Pour the remaining half of the 1/3 cup of cheese over the beans. Fold the top half of the tortilla over the bottom half and press down slightly. Set aside.

7. Repeat steps 2 to 6 for the remaining tortillas.

8. Preheat a frying pan over medium heat, about 2 minutes.

9. Carefully put 2 folded Quesadillas into the frying pan. Press down on the quesadillas with a spatula

10. Cook until the bottoms of the Quesadillas are lightly browned and crisp, about 2 to 3 minutes.

11. Carefully turn each quesadilla and cook on the second side until lightly browned and crisp, and the cheese inside is melted, about 2 to 3 minutes.

12. Place the quesadillasonto the baking pan in the oven to keep warm.

13. Repeat steps 9 to 12 for the remaining tortillas.

14. Take the baking pan from the oven then place the
Quesadillas on a cutting board. Cut each quesadilla in half using a chef's knife then cut again each piece in half to make four pieces.

?
Bean Quesadillas are delicious served with sour cream and salsa.

? This Bean Quesadillas recipe makes 16 pieces.

Chicken Quesadillas Recipe


Chicken Quesadillas Ingredients:

? 2 tablespoons olive oil

? 1/4 small cup chopped red onion

? 1 garlic cloves, minced

? 1/4 small cup chopped red and green pepper, combined

? 1/2 teaspoon chopped fresh coriander

? 1 chili peppers (to taste),minced

? 1 1/2 plum tomatoes, chopped

? 3/4 cup chopped cooked chicken

? 4 flour tortillas

? 1 cup grated Monterey Jack and cheddar cheese, combined

Chicken Quesadillas Recipes Directions:

1. In a large skillet, heat 2 tablespoons of the oil on medium heat. Add the red onion, garlic, peppers and coriander to the skillet and sauté until softened, about 5 minutes.

2. Add the chili peppers and tomatoes to the skillet and simmer for 3 minutes. Add the chicken to the skillet and stir well to combine.

3. In a medium-sized skillet, heat a thin layer of part of the remaining oil over medium-low heat.

4. Place a tortilla in the skillet and sprinkle with 1/4 cup of the cheese. Add the chicken mixture and then top with another 1/4 cup of the cheese. Cover with another tortilla.

5. Cook the Quesadillas on each side for 2 to 3 minutes, until the cheese has melted and the tortillas are lightly browned.

6. Transfer to a baking sheet and keep warm in a 250°F oven while you cook the remaining Quesadillas. Cut each quesadilla and serve.

? This Chicken Quesadillas recipe makes 2 servings.

? Quesadillas are delicious served with salsa, sour cream and guacamole.

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

530 Binomial Showdown Time limit exceeded

Post by uvasarker » Thu Dec 08, 2011 2:55 pm

Please, Help me
Why TLE?

Code: Select all

#include <math.h>

int main()
{
	long long n,k;
	while(scanf("%lld %lld",&n,&k)==2)
	{
		long long num=1,d=1,i,a;
		if(n==0 && k==0) break;
		
		long long min = n - k;

		for(i=n; i > min; i--)
			num = num * i;
		for(i=k; i > 1; i--)
			d = d * i;

		a = num/d;

		printf("%lld\n",a); 
	}

   return 0;
}


avatar
New poster
Posts: 8
Joined: Wed Nov 16, 2011 6:44 pm

Re: 530 woes

Post by avatar » Fri Dec 16, 2011 5:01 pm

for those who are getting WA try the following:::::
[/c]
input::::
45 0
15 9
0 0

output::::
1
5005

hope i helped u

davdigsb
New poster
Posts: 2
Joined: Fri Jan 06, 2012 3:33 pm

Re: 530 woes

Post by davdigsb » Fri Jan 06, 2012 3:36 pm

avatar wrote:for those who are getting WA try the following:::::
[/c]
input::::
45 0
15 9
0 0

output::::
1
5005

hope i helped u
yes you did. thanx a lot.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 530 Binomial Showdown Time limit exceeded

Post by brianfry713 » Sat Jan 07, 2012 12:11 am

Try the input 20000 20000, the answer should be 1.
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 530 Binomial Showdown Time limit exceeded

Post by uvasarker » Thu Feb 09, 2012 8:10 pm

Hi brianfry713,
thanks for helping.
But it's now WA. Here is my modified code please check it, please.

Code: Select all

#include <cstdio>
#include <cctype>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
	long double n, m;
	while(scanf("%Lf %Lf",&n,&m)==2)
	{
		long double t=0.0, t_fact=1.0, m_fact=1.0, n_fact=1.0, c, i, j;
		if(n==0 && m==0) break;
		
		if(m==1)
			cout<<n<<endl;
		else if(m==0) cout<<"1"<<endl;
		else
		{
			t=n-m;
			if(t>m)
			{
				for(i=n ; i>t ; i--)
				{
					n_fact=n_fact*i;
					if(m>0)
					{
						n_fact/=m;
						m--;
					}
				}
				c=n_fact;
				//m=m+1.0;
				if(m>1)
				{
					for(j=m ; j>=1 ; j--)
						m_fact*=j;	
					c=n_fact/m_fact;
				}
			}
			else
			{
				for(i=n ; i>m ; i--)
				{
					n_fact*=i;
					if(t>0)
					{
						n_fact/=t;
						t--;
					}
				}
				c=n_fact;
				//t=t+1.0;
				if(t>1)
				{
					for(j=t ; j>0 ; j--)
						t_fact*=j;
					c=n_fact/t_fact;
				}
			}
			
			printf("%.0Lf\n",c);
		}
	}

   return 0;
}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 530 Binomial Showdown Time limit exceeded

Post by brianfry713 » Mon Feb 13, 2012 11:09 pm

Don't use long double, use unsigned long long.
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 530 Binomial Showdown Time limit exceeded

Post by uvasarker » Tue Feb 14, 2012 1:23 pm

Hi boss,
Still WA...

Code: Select all

#include <cstdio>
#include <cctype>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
       unsigned long long n, m;
       while(scanf("%llu %llu",&n,&m)==2)
       {
          unsigned long long t=0, t_fact=1, m_fact=1, n_fact=1, c, i, j;
          if(n==0 && m==0) break;
          
          if(m==1)
             cout<<n<<endl;
          else if(m==0) cout<<"1"<<endl;
          else
          {
             t=n-m;
             if(t>m)
             {
                for(i=n ; i>t ; i--)
                {
                   n_fact=n_fact*i;
                   if(m>0)
                   {
                      n_fact/=m;
                      m--;
                   }
                }
                c=n_fact;
                //m=m+1.0;
                if(m>1)
                {
                   for(j=m ; j>=1 ; j--)
                      m_fact*=j;   
                   c=n_fact/m_fact;
                }
             }
             else
             {
                for(i=n ; i>m ; i--)
                {
                   n_fact*=i;
                   if(t>0)
                   {
                      n_fact/=t;
                      t--;
                   }
                }
                c=n_fact;
                //t=t+1.0;
                if(t>1)
                {
                   for(j=t ; j>0 ; j--)
                      t_fact*=j;
                   c=n_fact/t_fact;
                }
             }
             
             printf("%llu\n",c);
          }
       }

   return 0;
}



brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 530 Binomial Showdown Time limit exceeded

Post by brianfry713 » Wed Feb 15, 2012 12:00 am

Try the sample I/O.
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 530 Binomial Showdown Time limit exceeded

Post by uvasarker » Wed Feb 15, 2012 12:32 pm

Hi
Boss
Now, I use Pascale-Triangle formula to solve this problem. But, I am getting Runtime error. Please, help me.
Here is my code:

Code: Select all

Finally, I got it AC /* Removed */

dibery
Learning poster
Posts: 76
Joined: Sat Feb 23, 2013 4:16 pm
Location: Taiwan, Taipei
Contact:

Re: 530 woes

Post by dibery » Fri Jul 26, 2013 6:12 pm

Input:

Code: Select all

33 33
33 32
33 31
33 30
33 29
33 28
33 27
33 26
33 25
33 24
33 23
33 22
33 21
33 20
33 19
33 18
33 17
0 0
Output:

Code: Select all

1
33
528
5456
40920
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
1037158320
1166803110
Life shouldn't be null.

triplemzim
New poster
Posts: 48
Joined: Sat Apr 06, 2013 6:02 pm

Re: 530 woes

Post by triplemzim » Thu Aug 01, 2013 12:10 am

why getting runtime error???? please help...

Code: Select all

removed after AC
Last edited by triplemzim on Fri Aug 02, 2013 11:37 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 530 woes

Post by brianfry713 » Fri Aug 02, 2013 2:39 am

That is AC code.
Check input and AC output for thousands of problems on uDebug!

triplemzim
New poster
Posts: 48
Joined: Sat Apr 06, 2013 6:02 pm

Re: 530 woes

Post by triplemzim » Fri Aug 02, 2013 11:24 pm

i don't know but believe it or not i got RE after submitting that code... :(

Post Reply

Return to “Volume 5 (500-599)”