ProgrammingVery hardGATE CS · Campus placements
uint64_t computes 3 to the power 40 modulo 1000000007 with square-and-multiply, reducing after each multiplication. What is the result?
- A. 3486784401
- B. 953271190
- C. 1000000006
- D. 0
Correct answer: B. 953271190
Reducing after every multiply keeps each product below 2^64, so no overflow occurs. 3^40 mod 1000000007 equals 953271190. The value 3486784401 is 3^20 itself, a sign of using the wrong exponent.
More C Programming questions
- uint32t x = 0x7FFFFFFFu; x = x 2u + 1u; What is x?
- For an unsigned integer x, which expression clears the lowest set bit of x?
- uint8t a = 0xF0, b = 0x3C; uint8t c = a & ~b; What is c?
- uint16t a = 3, b = 5; printf("%d", (a - b) > 0); prints what?
- uint32t p = 65536u 65536u; What is p?
- uint64t f = 1; for (uint64t i = 1; i <= 21; i++) f = i; What is f after the loop?