ProgrammingVery hardGATE CS · Campus placements
Using fast exponentiation with reduction modulo 1000000007 after each multiplication, what is 2^100 mod 1000000007?
- A. 976371285
- B. 1024
- C. 1000000006
- D. 0
Correct answer: A. 976371285
Square-and-multiply reduces each step, and the result is 976371285. Computing 2^100 exactly and reducing once gives the same residue, while 1024 is only 2^10.
More C Programming questions
- int n = -1; uint64t u = (uint64t)n; What is u?
- uint32t fib(int n) iteratively computes a = 0, b = 1, then n times: t = a + b; a = b; b = t, with all arithmetic in uint32t. What is…
- int x = 5; x = x++; What is the outcome of this statement?
- uint16t h = 0; for each character c of "ABCDE", h = h 31 + c; with 65 for 'A' and so on. What is h at the end?
- Which function correctly tests whether an unsigned value x is a power of two, with x = 0 excluded?
- char b[6]; snprintf(b, sizeof b, "%s-%d", "abcdef", 12345); int r = snprintf(NULL, 0, "%s-%d", "abcdef", 12345); printf("%s %d", b, r)…