Skip to content
Embercode
✕
Contest setup and the judgeQuick quiz

Limits, overflow and modulo

8 questions. Covers Integer overflow and modulo arithmetic.

Questions 1 to 5 of 8

  1. 1. An AI writes int total = 0; and adds n values, each up to 10^9, with n up to 200,000. Local tests with 5 numbers pass. The judge says wrong answer on a large test. What is the most likely cause?
  2. 2. The problem has n up to 200,000. An AI proposes checking every pair with two nested loops. Which judgement is right?
  3. 3. Which line can overflow, and what fixes it? ``cpp int w = 100000, h = 100000; long long area = (long long)(w * h); ``
  4. 4. Binary search uses int mid = (lo + hi) / 2; with lo = 1500000000 and hi = 2000000000. The result is negative. Which replacement is correct?
  5. 5. What do these print? -7 % 3 in C++ with long long, and -7 % 3 in Python 3?

5 question(s) left on this page.