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);
}- A. 399645717
- B. 399645716
- C. 399645718
- 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
- What is printed? c #include <stdio.h> int clz16(unsigned short x) { int n = 0; while (!(x & 0x8000u)) { x <<= 1; n++; } return n; } int…
- What is printed? Assume ASCII character encoding. c #include <stdio.h> int main(void) { int d = 'z' - 'a'; char e = 'A' + d 2; printf("%d…
- What is printed? c #include <stdio.h> int main(void) { int m[2][3] = {{1, 2, 3}, {4, 5, 6}}; int (p)[3] = m; int q = (int )p + 4…
- What is printed? Assume unsigned short is 16 bits. c #include <stdio.h> int main(void) { unsigned short y = 60000; y += 10000…
- What is printed? c #include <stdio.h> void gen(int d, int v) { if (d == 0) { printf("%d ", v); return; } gen(d - 1, v 2 + 1); gen(d - 1, v…
- What is printed? c #include <stdio.h> unsigned inv(unsigned g) { unsigned n = 0; for (; g; g >>= 1) n ^= g; return n; } int main(void) {…