Question 61
HardWhat is the output of this code?
def crt(rems, mods):
x, M = ,
r, m (rems, mods):
x % m != r:
x += M
M *= m
x
(crt([, , ], [, , ]))
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is the output of this code?
def crt(rems, mods):
x, M = ,
r, m (rems, mods):
x % m != r:
x += M
M *= m
x
(crt([, , ], [, , ]))
8
53
23
105
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
def phi(n):
r, p = n, 2
while p * p <= n:
if n % p == 0:
while n % p == 0: n //= p
r -= r // p
p += 1
if n > 1: r -= r // n
return r
print(phi(100), phi(97), phi(1))
40 96 0
40 97 1
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
def nCr_mod(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
print(nCr_mod(10, 3, 13), nCr_mod(100, 50, 1_000_000_007) == __import__("math").comb(100, 50) % 1_000_000_007)
9 True
3 True
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
def sieve_spf(n):
spf = list(range(n + 1))
for i in range(2, int(n ** 0.5) + 1):
if spf[i] == i:
for j in range(i * i, n + 1, i):
if spf[j] == j: spf[j] = i
return spf
spf = sieve_spf(100)
x, f = 84, []
while x > 1:
f.append(spf[x]); x //= spf[x]
print(f)
[2, 2, 3, 7]
[4, 3, 7]
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
def egcd(a, b):
if b == 0: return a, 1, 0
g, x, y = egcd(b, a % b)
return g, y, x - a // b * y
g, x, y = egcd(240, 46)
print(g, 240 * x + 46 * y, pow(7, -1, 26))
2 0 15
2 2 15
Sign up free to see the answer and a step-by-step explanation.
How many positive divisors does 720 have, and what is their sum?
24 divisors, sum 2,418
30 divisors, sum 2,418
30 divisors, sum 2,400
36 divisors, sum 2,520
Sign up free to see the answer and a step-by-step explanation.
What is the remainder when 2¹⁰⁰ is divided by 7?
4
1
2
6
Sign up free to see the answer and a step-by-step explanation.
What is the highest power of 3 that divides 100!?
47
48
33
44
Sign up free to see the answer and a step-by-step explanation.
How many integers from 1 to 100 are divisible by neither 2 nor 5?
30
60
50
40
Sign up free to see the answer and a step-by-step explanation.
How many division steps does Euclid's algorithm take to compute gcd(89, 55)?
8
10
9
55
Sign up free to see the answer and a step-by-step explanation.
50 96 1
40 96 1
3 False
120 True
[2, 2, 21]
[2, 3, 7]
4 2 15
2 2 11