Content-Length: 267508 | pFad | https://github.com/cp-algorithms/cp-algorithms/commit/7952d74d27adfbd3cb977b5ac1f1351d31f249e6

94 cpp_tips: mention redefining ints · cp-algorithms/cp-algorithms@7952d74 · GitHub
Skip to content

Commit 7952d74

Browse files
authored
cpp_tips: mention redefining ints
1 parent 5456836 commit 7952d74

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/others/cpp_tips.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ References:
2020

2121
- `using namespace std;`: this saves lots of tedious typing of `std::` before all the standard library functions and objects. However, a blanket namespace import like this can cause name clashes, so don't name your variables or functions something common like `find` or anything from [this list](https://en.cppreference.com/w/cpp/symbol_index).
2222
- `#include <bits/stdc++.h>`: this is a catch-all implementation-defined header in g++ that avoids having a list of dozens of includes like `#include <vector>`, `#include <iostream>`, `#include <string>`, etc. It should work on any CP judge site, but it is not a standard header.
23+
- `#define int long long`: some people define `int` to always be (at least) 64-bit to avoid overflow issues, since most CP problems use numbers that fit in a 64-bit integer. However, be aware of unexpected issues:
24+
- C++ requires `main` to be a function returning `int` and not `long long`, so use `signed main` as a workaround.
25+
- Function calls like `min(x, 0)` may complain that `0` is type `int`.
26+
- May require twice as much memory than `int` and make the program slower, which may be important in extremely time-critical code.
27+
- Otherwise you can use `typedef long long ll` or use the appropriate fixed-width integer types like `int64_t`.

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/cp-algorithms/cp-algorithms/commit/7952d74d27adfbd3cb977b5ac1f1351d31f249e6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy