Skip to main content

Posts

How To calculate Trailing Zeros in N factorail | count Number of trailing zero in N! CSES problem solution

 How To calculate Trailing Zeros in N factorail | count Number of trailing zero in N! CSES problem solution - This problem is taken form CSES Introductory Problem set. Here You have to count number of trailing zero in N!. Problem Statement- Your task is to calculate the number of trailing zeros in the factorial  n ! n ! . For example,  20 ! = 2432902008176640000 20 ! = 2432902008176640000  and it has  4 4  trailing zeros. Input The only input line has an integer  n n . Output Print the number of trailing zeros in  n ! n ! . Constraints 1 ≤ n ≤ 10 9 1 ≤ n ≤ 10 9 Example Input: 20 Output: 4 Solution- Recommended practice yourself Before jumping to solution. Problem link- https://cses.fi/problemset/task/1618/ So here is A hidden logic behind solving this problem. Think Condition when zero comes as trailing zero when we multiply two numbers. Zero comes at the end when a number multiplied by 10. So we have to find How many times 10 can be formed in N!. since 10 is multiple is 2 and

modulo Property for competitive programming | Most Important properties of modulo,modulo property

 GCD Property for competitive programming - properties of modulo or modulo property play important role in competitive programming. Some of the Problems of competitive programming is directly asked based on properties of modulo or modulo property. So here are some most important Modulo Properties That you should know.   What is modulo operation:   The remainder obtained after the division operation on two operands is known as modulo operation. Operator for doing modulus operation is  ‘%’ . For ex: a % b = c which means, when a is divided by b it gives the remainder c, 7%2 = 1, 17%3 = 2.            Important properties of modulo- ( a + b) % c = ( ( a % c ) + ( b % c ) ) % c ( a * b) % c = ( ( a % c ) * ( b % c ) ) % c ( a – b) % c = ( ( a % c ) – ( b % c ) ) % c ( a / b ) % c = ( ( a % c ) / ( b % c ) ) % c Basic Euclidean Algorithm for GCD- If we subtract smaller number from larger (we reduce larger number), GCD doesn’t change. So if we keep subtracting repeatedly the larger of two,

CodeChef October Lunchtime Problem Solution | codechef Lunctime Problem solution

 CodeChef October Lunchtime Problem Solution | codechef Lunctime Problem solution - Codechef is one of the best coding website for competitive programming. Every month CodeChef conduct many contest so CodeChef lunchtime is one of a popular contest of CodeChef.  Codechef October Lunchtime 2020 is on 31st October. Lunchtime is a rated contest so you should must part on this contest. Contest Link- https://www.codechef.com/LTIME89/?itm_medium=hpbanner&itm_campaign=LTIME89 Problem 1- AND plus OR Sulution  till then you can  visit-  Codechef october cook off Contest Problem solution  and-  CodeChef Long challenge editorial | codechef long challenge solutions Join Telegram for Code Discussion and more editorial of upcoming coding contest - https://t.me/competitiveProgrammingDiscussion 

Decreasing Srrnmieeda October Cook off challenge Solution | Easy Explain Decreasing Srrmieeda

 Decreasing Srrnmieeda October Cook off challenge Solution | Easy Explain Decreasing Srrmieeda- Easy Explanation of Decreasing Srrnmieeda October Cook-off challenge Solution  With Code.Here Is Problem Statement. Problem Statement- You are given two integers  L L  and  R R . Find the smallest non-negative integer  N N  such that N % L > N % ( L + 1 ) > … > N % ( R − 1 ) > N % R . N % L > N % ( L + 1 ) > … > N % ( R − 1 ) > N % R . Here,  % %  is the modulo operator, so  A % B A % B  is the remainder of  A A  after division by  B B . For example,  11 % 3 = 2 11 % 3 = 2 . Input The first line of the input contains a single integer  T T  denoting the number of test cases. The description of  T T  test cases follows. The first and only line of each test case contains two space-separated integers  L L  and  R R . Output For each test case, print a single line containing one integer ― the smallest possible  N N , or  − 1 − 1  if no solution exists. It is guaranteed