Algorithm


Problem Name: 2 AD-HOC - beecrowd | 2355

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

Brazil and Germany

 

By Alexandre Davis, UFMG BR Brazil

Timelimit: 1

Brazil and Germany was a unforgettable match. In this match, Germany scored 7 times in 90 minutes, while Brazil scored only 1. It was an incredible milestone in history of brazilian soccer, so Leonardo decide make a web page for brazilians never forget this splendid day.

The page shows the scoreboard of the match if it was still going on since that fateful July 8, 2014, considering the same rate of scores (like in figure below). Therefore, Leonardo ask for your help to calculate the scoreboard of the match showed on his web page.

 

 

 

 

Observations

As the web site want shock his fans, the Germany scores should round up while Brazil scores should round down.

 

Input

 

The input is composed for one number N (90 ≤ N ≤ 109) indicating how many minutes passed since the start of the match. It ends when N = 0.

 

Output

 

The output should write in only one line: “Brasil B x Alemanha A” where B and A are integers indicating how many goals Germany and Brazil did, respectively.

 

 

 

Input Sample Output Sample

90
100
180
0

Brasil 1 x Alemanha 7
Brasil 1 x Alemanha 8
Brasil 2 x Alemanha 14

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


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

int main (void)
{

	double minutos, feitosBrasil, feitosAlemanha;

	while (true)
	{

		scanf("%lf", &minutos);

		if (minutos == 0)
			break;

		feitosBrasil = floor(minutos / 90);
		feitosAlemanha = ceil(7 * minutos / 90);

		printf("Brasil %.lf x Alemanha %.lf\n", feitosBrasil, feitosAlemanha);

	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
90
100
180
0

Output

x
+
cmd
Brasil 1 x Alemanha 7
Brasil 1 x Alemanha 8
Brasil 2 x Alemanha 14

#2 Code Example with Python Programming

Code - Python Programming


from math import floor as chao
from math import ceil as cezin
while True:
    x=int(input())
    if x==0:break
    brasa=chao(x/90)
    alema=cezin(7*x/90)
    print(f"Brasil {brasa} x Alemanha {alema}")
Copy The Code & Try With Live Editor

Input

x
+
cmd
90
100
180
0

Output

x
+
cmd
Brasil 1 x Alemanha 7
Brasil 1 x Alemanha 8
Brasil 2 x Alemanha 14

#3 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const input = readFileSync("/dev/stdin", "utf8").split("\n")

function BrazilVSGermanyBoardFromTime(time = 90) {
	const Brazil = Math.floor((time / 90) * 1)
	const Germany = Math.ceil((time / 90) * 7)

	return [Brazil, Germany]
}

function main() {
	const responses = []

	for (const time of input) {
		if (time == "0") break

		const [BRGols, DEGols] = BrazilVSGermanyBoardFromTime(Number.parseInt(time, 10))
		responses.push(`Brasil ${BRGols} x Alemanha ${DEGols}`)
	}

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

main()
Copy The Code & Try With Live Editor

Input

x
+
cmd
90
100
180
0

Output

x
+
cmd
Brasil 1 x Alemanha 7
Brasil 1 x Alemanha 8
Brasil 2 x Alemanha 14
Advertisements

Demonstration


Previous
#2353 Beecrowd Online Judge Solution 2353 Just in Time Solution in C, C++, Java, Js and Python
Next
#2366 Beecrowd Online Judge Solution 2366 Maratona Solution in C, C++, Java, Js and Python