Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all 39796 articles
Browse latest View live

Need some explanation on the combinatorics formula nCr= n-1Cr + n-1Cr-1

$
0
0

nCr= n-1Cr + n-1Cr-1 is a famous recursive equation for computing nCr , where nCr means number of ways selecting r objects from n objects. I have read in high school the logical meaning of this formula. I remember my teacher saying that to calculate number of ways of selecting r objects from n objects(nCr) , we can either discard object at r postion(i.e n-1Cr-1) , or we can include the object at r position (i.e n-1Cr).but I don't understand this logic now ..!! can someone plz explain me this with some example or any editorial..?? Thank you.


Counting sort is called stable and non-comparison sort.

$
0
0

Why counting sort is called stable and non-comparison sort?

C# How to display all elements of array as a single number?

$
0
0

I have an int array .

int[] numbers = new int[5] {1, 2, 3, 4, 5};

How can all the elements of this array displayed as a single number from last index to 0th index.In this case , it has to be 54321.

need help to solve - hidden password (ACM 2003, abridged)

Describe in what extent dynamic programming performs better than greedy approach.

$
0
0

Please - Describe in what extent dynamic programming performs better than greedy approach.

Difference between dynamic programming and greedy approach.

$
0
0

What is the differences between dynamic programming and greedy approach?

No editorial :(

sorting of vectors or arrays

$
0
0

I am working on a problem and continuously getting TLE. I want to know if there's another way to sort a vector.

Currently I am using

sort(v.begin(),v.end());

Remember I want to avoid the TLE so please suggest me a better method to sort a vector or an array.

EDIT: The goal of the problem is to sort a string in alphabetical order. I am currently using a vector of <char>.


Count Negative Integers in Matrix .

$
0
0

How to Count Negative Integers in Matrix ?

is my solution correct to this problem https://www.codechef.com/COSE2017/problems/GGCURR ?

$
0
0

I can't submit the solution so I am asking here -

#include "bits/stdc++.h"
using namespace std;

int main()
{
int t;
cin >> t;

while(t--)
{
    int n, a, b;
    cin >> n >> a >> b;
    int ok[100000+1];
    memset(ok, 0, sizeof ok);
    queue<int> q;
    q.push(0);
    while(!q.empty())
    {
        int x = q.front();
        // cout << x;
        ok[x] = 1;
        q.pop();
        if(x+a <= 100000 && ok[x+a] == 0){q.push(x+a);ok[x+a]=1;}
        if(x+b <= 100000 && ok[x+b] == 0){q.push(x+b);ok[x+b]=1;}
    }
    int a1[n+1];
    int c = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a1[i];
        if(ok[a1[i]] == 1)
            c++;
    }
    cout << c << " " << n-c << "\n";
}
return 0;

}

problem in taking mixing inputs

$
0
0

I am trying to solve some problem. problem having test cases and inputs like some inputs are integer and some are character type. when I am correctly read integer inputs but when I am taking char type inputs then program is running out of control means it doesn't read input correctly and doesn't execute accordingly.Please help. thanks in advance.Currently i am doing coding in c++.

Is my solution for GGCURR correct?

$
0
0

I can't submit the solution so I am asking here -

#include "bits/stdc++.h"
using namespace std;

int main()
{
int t;
cin >> t;

while(t--)
{
    int n, a, b;
    cin >> n >> a >> b;
    int ok[100000+1];
    memset(ok, 0, sizeof ok);
    queue<int> q;
    q.push(0);
    while(!q.empty())
    {
        int x = q.front();
        // cout << x;
        ok[x] = 1;
        q.pop();
        if(x+a <= 100000 && ok[x+a] == 0){q.push(x+a);ok[x+a]=1;}
        if(x+b <= 100000 && ok[x+b] == 0){q.push(x+b);ok[x+b]=1;}
    }
    int a1[n+1];
    int c = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a1[i];
        if(ok[a1[i]] == 1)
            c++;
    }
    cout << c << " " << n-c << "\n";
}
return 0;

}

Can someone provide the editorial for BASE?

capimove time

$
0
0

some help needed to deal with time complexcity,any suggestion which algorithm should i use to decrease the time ,or some problems in codechef which can help me dealing tle.

Different type of Bug

$
0
0

Here is a new bug I found today about 2-3 times.

Image

There is a random username everytime I open the top contibutor's list on the top left side instead of showing up my name. Even the standing page is according to the random username.

@admin please look into the matter.


User Account @ CodeChef

$
0
0

@admin I have logged in with my account at CodeChef then why i am seeing other user name in CodeChef Discuss?

rashedcs

SRTX16E - Editorials

Swapping integers in one line

$
0
0

Is there any trick to sort the integers in just a line?

Inoi 2017 discussion

$
0
0

How was your test experience and your performance?

My center was at IIT Patna and the test experience was just fine after the 1 hour delay. Much better than last year.

Solved the first one by a simple dfs. No idea why it was included in INOI. For the second one I did a brute force specific to the first two test cases. This brought my total score to 150

Weak test cases in TOURISTS

Viewing all 39796 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>