ProgrammingVery hardCompetitive coding (CP)

What is printed? Assume long long is 64 bits and that the product fits in a long long.

What is printed? Assume long long is 64 bits and that the product fits in a long long.
#include <stdio.h>
int main(void) {
    long long p = 3037000499LL * 3037000500LL;
    printf("%lld", p % 1000000007LL);
}
  1. A. 399645717
  2. B. 399645716
  3. C. 399645718
  4. D. 399645710

Correct answer: A. 399645717

3037000499 * 3037000500 = 9223372033963249500, which is below 2^63 - 1, so the product is exact. Reducing it modulo 1000000007 gives 399645717.

More C Programming questions

Exams that ask this topic