#K79122. Perfect Numbers Operations

    ID: 35239 Type: Default 1000ms 256MiB

Perfect Numbers Operations

Perfect Numbers Operations

You are given an operation related to perfect numbers. A perfect number is an integer \(n\) such that the sum of its proper divisors equals \(n\), i.e., \(\sum_{i=1}^{n-1} \text{if } i \mid n = n\). In this problem, you are required to perform one of the following operations based on the input command:

  • isPerfect: Given an integer \(n\), determine whether it is a perfect number. Print True if it is, otherwise print False.
  • nextPerfect: Given an integer \(n\), find and print the smallest perfect number that is greater than \(n\).
  • perfectSeries: Given two integers \(count\) and \(start\), generate and print a series of \(count\) perfect numbers, starting from \(start\). If \(start\) itself is a perfect number, include it; otherwise, start with the next perfect number greater than \(start\).

All input should be read from standard input and all output printed to standard output.

inputFormat

The input consists of two lines:

  • The first line is a string that denotes the operation type. It can be one of the following: isPerfect, nextPerfect, or perfectSeries.
  • The second line contains one or more integers separated by spaces corresponding to the parameters of the chosen operation:
    • If the operation is isPerfect, there will be one integer \(n\).
    • If the operation is nextPerfect, there will be one integer \(n\).
    • If the operation is perfectSeries, there will be two integers: \(count\) and \(start\).

outputFormat

Print the result on standard output as follows:

  • For isPerfect: output True or False.
  • For nextPerfect: output a single integer representing the next perfect number greater than \(n\).
  • For perfectSeries: output a sequence of perfect numbers separated by a single space.
## sample
isPerfect
6
True