Counting Triplets

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 128.0 MB

Description

Given an integer x, count the number of ordered triplets (a, b, c) of positive integers such that:

  • a + b + c ≤ x.
  • The sum (a + b + c) must be a prime number.
  • Order matters (i.e., (1,1,2) ≠ (1,2,1)).
  • Each of a, b, and c must be greater than 0.

Input

• A single integer x (1 ≤ x ≤ 1000).

Output

• Print a single integer — the number of valid triplets (a, b, c) that satisfy the conditions.

Sample

Input Output
5
7

Explanation:
For x = 5, the valid ordered triplets where the sum is a prime number are:

  • (1,1,1) → sum = 3 (prime)
  • (1,1,3) → sum = 5 (prime)
  • (1,2,2) → sum = 5 (prime)
  • (1,3,1) → sum = 5 (prime)
  • (2,1,2) → sum = 5 (prime)
  • (2,2,1) → sum = 5 (prime)
  • (3,1,1) → sum = 5 (prime)

Total valid triplets: 7

Intra LU IEEE Beginner Programming Contest

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
8
Start at
2025-02-26 05:30
End at
2025-02-26 07:30
Duration
2.0 hour(s)
Host
Partic.
42