ZeroJudge A799: Country of Integrity

Long, long ago, there was a country called "Country of Integrity." The people of this country were very honest in everything they did, living with integrity. As a result, the country was peaceful, happy, and prosperous.

However, there was an unwritten custom in this country: they disliked negative numbers. They regarded negative numbers as symbols of evil, so they detested seeing negative numbers. They would simply remove the negative sign whenever they saw a negative number. For example, "-1" would become "1."

Xiao Hua is a middle school student who has just moved to the Country of Integrity from another country. Every time he writes a negative number on his math test paper, he gets severely beaten by other classmates and teachers. Can you help him?

Sample Inputs/Outputs

Sample Input(s)Sample Output(s)
The input consists of only one line containing an integer N.
For 40% of the test cases, it is guaranteed that N ≥ 0.
For 100% of the test cases, it is guaranteed that −2147483647 < N < 2147483647.
Please output an integer representing the number favored by the country of Positive Values.
-55

Thought Process

Output the absolute value of N directly using abs(N).

Sample Code-ZeroJudge A799: Country of Integrity

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  printf("%d\n", abs(N));
}

//Z.O.J. A799
//Dr. SeanXD

Comments