Format Euler Code
Overview
Apply the Euler C++ code-style rules so solutions are consistent, readable, and compliant. Focus on formatting, structure, and required conventions while preserving correctness.
Guidelines
- Keep helper functions and structs above
main(); keepmain()short and focused on orchestration and output. - Use a single translation unit; avoid extra headers unless the problem demands it.
- List only required standard headers explicitly; avoid mega-headers.
- Qualify all standard library usage with
std::; do not useusing namespace std;. - Use
static_cast<...>for conversions; avoid C-style casts. - Prefer fixed-width integers (
std::uint64_t,std::int64_t) and keep constantsconstorconstexprnear use. - Mark file-scope helpers as
static(orstatic inlinefor small helpers). - Prefer
std::vector/std::array;reserve()or pre-size when size is known; usestd::size_tfor indexing by size. - Use clear loops with early-continue/early-return; avoid unnecessary recursion.
- Use
std::ios::sync_with_stdio(false); std::cin.tie(nullptr);when reading input. - End final output with
std::endl. - Keep comments short and only for non-obvious math or logic; use ASCII only; never reference AGENTS instructions.
- Use
<primesieve.hpp>for prime generation when needed; use Boost multiprecision only when bounds require it.
Quick Workflow
- Scan the file for style violations: includes, namespaces, helper placement, types, casts, and I/O setup.
- Apply the minimal edits needed to conform to guidelines without changing logic.
- Re-check for unnecessary headers, incorrect types, or missing
statichelpers. - Confirm the final output line ends with
std::endl. - Confirm that the program output remains unchanged compared to prior to the code updates.
微信扫一扫