Statistics

Problem Statement for "IrreducibleNumber"

Problem Statement

You are given a int[] A. An integer K is irreducible with respect to A if K cannot be represented as a sum of one or more elements from A, where each element of A may be used at most once. Return the smallest positive integer that is irreducible with respect to A.

Definition

Class:
IrreducibleNumber
Method:
getIrreducible
Parameters:
int[]
Returns:
int
Method signature:
int getIrreducible(int[] A)
(be sure your method is public)

Constraints

  • A will contain between 1 and 3 elements, inclusive.
  • Each element of A will be between 1 and 100, inclusive.

Examples

  1. {1,1}

    Returns: 3

    1 can be expressed as 1, and 2 can be expressed as 1+1.

  2. {1,2}

    Returns: 4

  3. {1,3}

    Returns: 2

  4. {1,2,4}

    Returns: 8

  5. {4, 1, 3}

    Returns: 2

  6. {1,1,1}

    Returns: 4

  7. {100,100,100}

    Returns: 1

  8. {1,2,1}

    Returns: 5

  9. {1,3,7}

    Returns: 2

  10. {2,4,6}

    Returns: 1

  11. {4,2,1}

    Returns: 8

  12. {100,1,2}

    Returns: 4

  13. {3,2,1}

    Returns: 7

  14. {1}

    Returns: 2

  15. {2}

    Returns: 1

  16. {2 }

    Returns: 1

  17. {1, 2, 4 }

    Returns: 8

  18. {15, 19 }

    Returns: 1

  19. {4, 5, 6 }

    Returns: 1

  20. {100 }

    Returns: 1

  21. {1, 1, 3 }

    Returns: 6

  22. {1, 2, 3 }

    Returns: 7

  23. {3 }

    Returns: 1

  24. {2, 6, 8 }

    Returns: 1

  25. {1 }

    Returns: 2

  26. {2, 3, 4 }

    Returns: 1

  27. {1, 1, 1 }

    Returns: 4

  28. {100, 100, 100 }

    Returns: 1

  29. {1, 3, 1 }

    Returns: 6

  30. {1, 2, 2 }

    Returns: 6

  31. {3, 1, 2 }

    Returns: 7

  32. {3, 4, 5 }

    Returns: 1

  33. {1, 3, 2 }

    Returns: 7

  34. {5, 10, 1 }

    Returns: 2

  35. {1, 2, 1 }

    Returns: 5


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: