👨🍳Basic Math - Codechef
Q1:
The chef wants to become fit for which he decides to walk to the office and return home by walking. It is known that Chef's office is X km away from his home.
If his office is open 5 days a week, find the number of kilometers the Chef travels through office trips in a week.
Q1:
Count Prime
Q1:
Count PrimeSolve by using Sieve of Eratosthenes
Segmented Sieve
GCD Formula: Find gcd until one of the parameters becomes zero
gcd(a - b, b)
gcd(a % b, b)
LCM & GCD Relation: LCM(a, b) * GCD(a, b) = a * b
Greatest Common Factor & Highest Common Factor
Topic: Modular Arithmetic
( a%m + b%m) % m = (a + b) % m
(a%m − b%m) % m = (a − b) % m
(a%m * b%m) % m = (a * b) % m
Q3:
Modular Exponentiation --> Notes Page # 05
Q3:
Modular Exponentiation --> Notes Page # 05Using Fast Exponentiation Algorithm T.C: O(logn)
Last updated
Was this helpful?