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.
Need some explanation on the combinatorics formula nCr= n-1Cr + n-1Cr-1
Counting sort is called stable and non-comparison sort.
Why counting sort is called stable and non-comparison sort?
C# How to display all elements of array as a single number?
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)
Can anyone help me to solve hidden password (ACM 2003, abridged) problem ?
link : https://icpcarchive.ecs.baylor.edu/index.php?option=onlinejudge&page=show_problem&problem=756
spoj link : http://www.spoj.com/problems/MINMOVE/
I found many solutions which use suffix array but I didn't get anyone of them. I know what is suffix array but don't know how to apply it here. I just want method to solve this problem.
Describe in what extent dynamic programming performs better than greedy approach.
Please - Describe in what extent dynamic programming performs better than greedy approach.
Difference between dynamic programming and greedy approach.
What is the differences between dynamic programming and greedy approach?
No editorial :(
Can anyone please provide the editorial of the question Our Base is Under Attack Thanks in advance :)
sorting of vectors or arrays
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 .
How to Count Negative Integers in Matrix ?
is my solution correct to this problem https://www.codechef.com/COSE2017/problems/GGCURR ?
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
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?
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?
Can anyone please provide the editorial of the question Our Base is Under Attack Thanks in advance :)
capimove time
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
Here is a new bug I found today about 2-3 times.
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
@admin I have logged in with my account at CodeChef then why i am seeing other user name in CodeChef Discuss?

SRTX16E - Editorials
PROBLEM LINK:
Author:Priyanshu Jain
DIFFICULTY:
MEDIUM
PREREQUISITES:
DP, Math etc.
AUTHOR'S AND TESTER'S SOLUTIONS:
Author's solution can be found here.
Swapping integers in one line
Is there any trick to sort the integers in just a line?
Inoi 2017 discussion
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
@admin, @satyaki3794 please update the test cases as my solution https://www.codechef.com/viewsolution/12590357 got accepted it should not be accepted for the cases I have mentioned in the code .
thanks