Algorithm


Problem Name: beecrowd | 3076

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3076

History Exercise

 

By Guilherme Londe, PUC Goiás BR Brazil

Timelimit: 1

After a very good history class - suceeding a very poor math class - some students from a specific school are in doubt on a simple problem. The teacher asked them about the numeric value (for the sake of simplicity, it must be in decimal and should contain arabic algarisms) of the century of a given year but, as only few students got it, she decided to ask you to help creating a program that does exactly this for educational purposes.

For those who not remember this history class, the century 1, for example, means the years among 1 and 100, the century 2 the years among 101 and 200, the century 3 the years among 201 and 300 and so on.

 

Input

 

The input contains several test cases and is finished by the end-of-file. Each line is a new test case and contains a single integer N (1 ≤ N ≤ 109), that means the value of some year that should be processed.

 

Output

 

For each test case, output a line with the value of the century of the corresponding year.

 

 

 

Input Sample Output Sample

1
999
2000
2001

1
10
20
21

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
#include <math.h>

typedef unsigned long long ullint;

int main(int argc, char **argv)
{
    
    ullint n;

    while (~scanf("%llu", &n))
        printf("%.lf\n", ceil(n / 100.0));

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 999 2000 2001

Output

x
+
cmd
1 10 20 21

#2 Code Example with Javascript Programming

Code - Javascript Programming


const { createReadStream } = require("node:fs")
const { createInterface } = require("node:readline")

//// READING FILE | STREAMS ////
class LineReader {
	/**
	 * @param {import("node:fs").PathLike} path
	 * @param {BufferEncoding} encoding
	 * @return {import("node:readline").ReadLine}
	 */
	static createReadLineInterface(path, encoding = "utf8") {
		const readStreamOptions = {
			encoding: encoding,
			flags: "r",
			emitClose: true,
			autoClose: true
		}

		return createInterface({
			input: createReadStream(path, readStreamOptions),
			crlfDelay: Infinity,
			terminal: false
		})
	}

	/**
	 * @param {import("node:fs").PathLike} path
	 * @param {BufferEncoding} encoding
	 */
	static create(path, encoding) {
		const RLI = LineReader.createReadLineInterface(path, encoding)

		let EOF = false

		const nextLineGenerator = (async function* () {
			for await (const line of RLI)
				yield line
		})()

		RLI.once("close", () => { EOF = true })

		return {
			hasNextLine: () => !EOF,
			nextLine: async (/** @type {unknown} */ fn) => {
				const { value } = (await nextLineGenerator.next())
				return (typeof fn === "function") ? fn(value) : value
			},
			close: () => RLI.close()
		}
	}
}

//// MAIN ////
async function main() {
	const PATH = "/dev/stdin"
	const ENCODING = "utf8"

	const output = []
	const lineReader = LineReader.create(PATH, ENCODING)

	const helper = (line = "") => Number.parseInt(line, 10)
	const nextLine = lineReader.nextLine.bind(lineReader, helper)

	while (lineReader.hasNextLine()) {
		const N = await nextLine()
		if (Number.isNaN(N)) break
		else output.push(Math.ceil(N / 100))
	}

	if (lineReader.hasNextLine())
		lineReader.close()

	console.log(output.join("\n"))
}

main()

Copy The Code & Try With Live Editor

Input

x
+
cmd
1 999 2000 2001

Output

x
+
cmd
1 10 20 21

#3 Code Example with Python Programming

Code - Python Programming


while True:
   try: print(int(0.99+(int(input())*0.01)))
   except: break
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 999 2000 2001

Output

x
+
cmd
1 10 20 21
Advertisements

Demonstration


Previous
#3068 Beecrowd Online Judge Solution 3068 Meteoros Solution in C, C++, Java, Js and Python
Next
#3084 Beecrowd Online Judge Solution 3084 Old Clock Solution in C, C++, Java, Js and Python