Did the Average Pass?

0.5s 256M

Ming took \(n\) subjects this semester, and his total score is \(total\). The teacher says that he passes only if his average score is at least \(60\). Determine whether Ming passes this semester.

When \(n > 0\), the average score is computed using integer division, so the decimal part is discarded.

Note that if \(n\) is \(0\), he has not taken any subject yet, so there is no average score. In this case, he is considered not passing. In this case, \(total\) is guaranteed to be \(0\).

Ming tried to write the following program, but it contains a mistake. Think about what is wrong with it, then write a correct program.

#include <iostream>
using namespace std;
int main() {
    int total, n;
    cin >> total >> n;
    if (total / n >= 60 && n != 0) cout << "Pass" << endl;
    else cout << "Fail" << endl;
    return 0;
}

Input

The input contains one line with two integers \(total\) and \(n\), separated by a space.

Constraints

  • \(0 \le total \le 10000\)
  • \(0 \le n \le 100\)
  • If \(n = 0\), then \(total = 0\)

Output

If Ming passes, output Pass; otherwise, output Fail.

Sample Input 1

180 3

Sample Output 1

Pass

Sample Explanation 1

The average score is \(60\), so it reaches the passing standard.

Sample Input 2

179 3

Sample Output 2

Fail

Sample Explanation 2

The average score is computed using integer division: \(179 / 3 = 59\), which is less than \(60\).

Sample Input 3

0 0

Sample Output 3

Fail

Sample Explanation 3

\(n = 0\) means no subject has been taken yet, so there is no average score and Ming is considered not passing.

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test: about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test has a 15 second wall-clock cap; sample tests use the problem time limit, the same as the official judge
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.