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

Invitation to ProCon Junior 2018

$
0
0

"Code to fight, Code to survive, Code to win!"

Hello Everyone!

I would like to invite you all to participate in ProCon Junior to be held on CodeChef. It will begin at 19:30 IST on August 11, 2018.

The problems have been made by me (prakhar17252), Madhav Sainanee (madhav_1999) and Tanmay Bansal (tanmay28).

You will be given 7 problems to solve in 2.5 hours. The competition is open for all and rated for Div-2.

Top school students studying between classes VI-XII (or equivalent) in an Indian school will then be invited to the onsite finals to be held at Esya'18, the Technical Fest of IIIT-Delhi.

School Students, register here for onsite finals: bit.ly/PRCNJR18

Prizes worth Rs. 20000 for the top rankers in the onsite finals.

This is my first time hosting a contest, and that too a rated one! Hope you all like the problems!

Hope everyone has high ratings!

Good Luck!

Happy Coding!


small factorial

$
0
0

include<stdio.h>

int main() { int t,a[100],i,f,j; scanf("%d\n",&t); for(i=0;i<t;i++) { scanf("%d\n",&a[i]); } for(i=0;i<t;i++) { f=1; for(j=1;j<=a[i];j++) { f=f*j; } printf("%d\n",f); } return 0; } i am not undustanding why it is giving me wrong answer as it is running fine in turbo.

In FRGTNLNG question Which test case is getting failed?

$
0
0
iterations = int(input()) 
while iterations :
    numberOfWords, numberOfLines = map(int, input().split())
    wordsDictionary = {};
    statusString = ""
    for word in input().split():
        wordsDictionary[ word ] = "NO"
    #print( wordsDictionary )
    while numberOfLines :
        sentence = input().split()[ 1: ]
        #print( line )
        for sentenceWords in sentence:
            if sentenceWords in wordsDictionary:
                wordsDictionary[ sentenceWords ] = "YES"
        numberOfLines -= 1
    for word in wordsDictionary:
        statusString += ( wordsDictionary[ word ] + " ")
    print( statusString[ : -1 ] )
    iterations -= 1

Do I need to register for the CodeChef monthly contests (Long and Cook-Offs) seperately

$
0
0

I want to participate in the coming month's contest. Can I participate? Do I need to register for the CodeChef monthly contests (Long and Cook-Offs) every time

sir can you tell me why this program is wrong

$
0
0

Problem Code: FCTRL2

include<stdio.h>

int factorial(int n) { return(n == 1 || n==0) ? 1: n * factorial(n -1);

} int main() { int i,t,n[100]; scanf("%d",&t); for(i=1;i<=t;i++) { scanf("%d",&n[i]); } for(i=1;i<=t;i++) { printf("%d \n",factorial(n[i])); }

return 0;

}

samsung hiring challenge

$
0
0

sir plz provide your expected inputs or else how would we know that our program is right or wrong because my code is matching the inputs nd outputs given in the description

Why am I getting worng answer ?

$
0
0

/Program to add two numbers/

include<iostream>

using namespace std; int main() { int T,a,b; cin>>T; /Entering the number of iterations/

for (int i=0; i<=T;i++)
{
    cin>>a>>b;
    int c = a+b;       /*Performing addition*/
    cout<<c<<endl;

};

return 0;

}

why my program is showing run time error

$
0
0

i build the "bob" program and compiled and ran it in my code blocks and it ran successfully without any errors and i also checked all possible outcomes of the program and i havent found any logical error hence i would really like to know what was my mistake!!


Login problem

$
0
0

hello, I am using codechef with my gmail login. so now I want to login using username and password in same account can I do so? I tried to login with username and password but not able to do so..help!!

T24 - Editorial

$
0
0

PROBLEM LINK:

[Contest] T24

Author:Jitendra Yadav

DIFFICULTY:

SIMPLE

PROBLEM:

You are given N number of questions and K are the number of choices you get for each question. You have to find the sum of total number of players who has attempted ith question. The answer can be very large therefore, you are required to print (sum of total number of players) % 10^9+7.

EXPLANATION:

Suppose you are given 3 questions and each question has 3 choices. So, you need to find the players for each question. For 1st question, 3^3=27 (there are 3 choices each for 3 questions) players played then for 2nd question, 3^2 = 9 (there are 3 choices each for 2 questions left) players played and finally for 3rd question, 3^1 = 3 (there are 3 choices each for 1 question left) players played.

So, the sum of total players played is 27+9+3=39.

Now you need to calculate the following operation i.e. 39%10^9+7 which will give you 39 as the output.

AUTHOR'S SOLUTIONS:

Author's solution can be found here

my code is not running

$
0
0

include<conio.h>

include<stdio.h>

main() { char x,A,E,I,O,U; printf("ENTER THE ALPHABET YOU WANT TO CHECK"); scanf("%d",&x); if(x== A||E||I||O||U) { printf("vowel"); } else { printf("CONSONANT"); } }

Python input error

$
0
0

When i try to run a code in python on codechef it gives EOF error.

But the same thing if run with custom input it runs perfectly.

EOF error but works perfectly with custom input

$
0
0
def nCm(n,m):
if m==0:
    return 1
if m==n:
    return 1

return int((n/m)*nCm(n-1,m-1))

num_test=int(input())

for test in range(num_test):

N,K=[s for s in map(int, input().split())]

print(nCm(N-1,K-1))'

Why does it give EOF error?

shknum august challenge

$
0
0

how can use power function pow in the codechef

SMPAIR - Editorial

$
0
0

Problem link : contestpractice

Difficulty : CakeWalk

Pre-requisites : Sorting

Problem : Given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i< jN

Explanation

This problem was the easiest one in the set and it was intended to enable everybody to get some points.

How to get 13 points

Here you have only two integers a1 and a2, so the only possible sum will be a1+a2.

How to get 60 points

The constraints were designed in such a way that you can iterate through all the possible pairs (i, j), where 1 ≤ i< jN and check for every obtained sum, whether it's the minimal one.

How to get 100 points

The answer is basically the sum of the minimal and the second-minimal element in the array. So you can simply iterate through all the numbers, keeping track of the minimal and the second-minimal number. Or if your programming language has built-in sorting, you can act even simpler, because after the sorting of the array in increasing order, the required minimal and the second-minimal will be the first and the second elements of the sorted array.

Related links

  • Reference in the built-in sorting for C++ users

Solutions : settertester


https://www.codechef.com/problems/HS08TEST

$
0
0

Whenever run this code i get wrong answer can someone help me in notifying the error: code:

include<iostream>

include<iomanip>

using namespace std; int main() { int x,i; float bal; cout<<"\nEnter the balance amount"; cin>>bal; cout<<"\nEnter withdraw amount"; cin>>x; if(x%5==0 && x+0.5<bal) { bal=bal-x-0.50; cout<<setprecision(2)<<bal; } else cout<<setprecision(2)<<bal; return 0; }

T23 - Editorial

$
0
0

PROBLEM LINK:

[Contest] T23

Author:Nandishwar Garg

DIFFICULTY:

SIMPLE

PROBLEM:

You are given an array of size N. You have to find every possible subset of the elements in array. Then we have to check 3 conditions on these subsets:

  1. It should not be empty.
  2. It should not have any element in subset which divide other elements present in subset except 1.
  3. It should not have duplicate elements.

If it satisfies all the conditions then print yes otherwise print no.

EXPLANATION:

Suppose the array elements are 1,2 and 3. The subsets of these elements are {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}.

  1. None of these subsets are empty
  2. No element other than 1 is dividing another element
  3. No duplicate element is present.

So, you have to print yes.

Taking another example, the array elements are 2 and 4. The subsets of following elements are {2}, {4} and {2,4}.

  1. None of these subsets are empty
  2. In {2,4}, 2 is dividing 4 so it doesn’t satisfy the condition

Thus you have to print no as the output.

AUTHOR'S SOLUTIONS:

Author's solution can be found here

my code is not running

$
0
0

include<conio.h>

include<stdio.h>

main() { char x,A,E,I,O,U; printf("ENTER THE ALPHABET YOU WANT TO CHECK"); scanf("%d",&x); if(x== A||E||I||O||U) { printf("vowel"); } else { printf("CONSONANT"); } }

Python input error

$
0
0

When i try to run a code in python on codechef it gives EOF error.

But the same thing if run with custom input it runs perfectly.

EOF error but works perfectly with custom input

$
0
0
def nCm(n,m):
if m==0:
    return 1
if m==n:
    return 1

return int((n/m)*nCm(n-1,m-1))

num_test=int(input())

for test in range(num_test):

N,K=[s for s in map(int, input().split())]

print(nCm(N-1,K-1))'

Why does it give EOF error?

Viewing all 40121 articles
Browse latest View live


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