The Answer to the Ultimate Question of Life, the Universe, and Everything
You are given a partially specified program.
Make the program print 42. You must not modify the code beyond what you are told you can modify.
This problem is only available in C++.
The judge will run your code in a form that looks similar to the following:
#include <cstdio>
void foo(/* fill in blanks */) {
/* fill in blanks */
}
int main() {
const int* x;
USER_CALL(x);
std::printf("%d\n", *x);
return 0;
}
USER_CALL(x)is a macro you must define so that the judge callsfoocorrectly.- In other words:
USER_CALL(x)should expand to the actual function call (e.g., ifxwas an int andfootakes an int pointer, you might define#define USER_CALL(x) foo(&x)).
Requirements
The program must have defined behavior.
The value printed must always be
42, regardless of optimization level.Returning or storing the address of a local (stack) variable is not allowed, even if it appears to work.
You may not modify
main.You may choose the function signature of
fooand how it is called.No input or output other than the final printed integer.
Accepted 6/27
Acceptance 22%
Loading editor...
Sample Input:
Expected Output:
42