Training Site
Sideways banner 8b44c02b768aa359c4d0a2bce3b247c6d7ab888f8b26852e9bfc3659c8c25612

C++

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds

I/O and Documentation

  • Use either cin or scanf() to get input.
  • Use either cout or printf() to write output.
  • You are permitted to view cppreference.com during an NZIC contest. Although this website can be harder to read, it is often the most reliable and comprehensive source of information and it gets easier to understand the more you use it.

Program Structure

  • Make sure you have a main function with the int return type.
  • Make sure you never return any non-zero value in main, otherwise your program will fail with a Runtime Error.

Compiling

We recommend that you install and use GCC. Compile with these flags...

g++ -std=gnu++17 -O2 -o executablename.exe filename.cpp -lm


Compiler flags explanation:

To run the executable, type its name. On Linux and macOS it must be prepended with ./ (for example ./executablename).

Example

Adding two numbers. Numbers will be space separated on a single line.

#include <bits/stdc++.h>
using namespace std;

int main () {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
}


Submit

Sample Explanation

3 + 4 = 7

  • Sample Input 1

    3 4
    

    Sample Output 1

    7