Solution in C/C++

Solution in C/C++

All solutions, regardless of the programming language, are tested by an automatic system. The test system creates an isolated, empty environment for your program, compiles it and runs it several times with a different set of input data. After that, the test system compares the output of the program with the expected result using a special algorithm.

The test system does not analyze the program code, does not check its contents, formatting, variable names, program size, etc.

In case program uses files for input and output, standard input-output streams (stdin and stdout) are ignored. In case program uses standard input-output streams (stdin and stdout), the test system does not analyze any files created by the solution.

The input data always corresponds to the constraints specified in the problem statement. Your solution does not need to verify the correctness of the input, unless this explicitly mentioned in the problem statement. Be careful, the lines in the input data are separated by the newline character \nor by combination of the carriage return and new line symbols:\r\n. The program should correctly handle both formats.

All output data is considered to be answer for the test, so if your program displays additional messages, for example, "Enter a number" or "Answer:" the solution will not be accepted. Follow the instructions in the problem statement to format answer correctly.

You can submit solutions written in the C or C++ programming language using the C++ compiler. The test system uses g++ 6.3.0 compiler, which runs on the Alpine Linux 3.6. The compiler runs with the following parameters:

g++ -std=c++11 -O2 -fno-strict-aliasing -DEOLIMP -DEOLYMP -DONLINE_JUDGE -lm -x c++ source.cpp -o a.out

If the compiler returns an error, the solution is not tested and the test system marks solution as "Compilation Error". The error message generated by the compiler will be displayed on the solution page.

A solution for simple problem in C/C++:


int main() {
   int a = 0;
   scanf("%d", &a);
   printf("%d %d\n", a/10, a%10);
   return 0;

This example uses input and output streams (stdin and stdout) using the stdio.h library. You can also use any other libraries provided with the Gnu C++ compiler.


Below you will find some of the types available in C++ along with their minimum and maximum values ​​for the C++ compiler.

TypeSizeMinimum valueMaximum value
char1 bytes-128127
int4 bytes-21474836482147483647
short int2 bytes-3276832767
long8 bytes-92233720368547758089223372036854775807
float4 bytes1.17549e-383.40282e+38
double8 bytes2.22507e-3081.79769e+308
wchar_t4 bytes-21474836482147483647