## Algorithm

Problem Name: beecrowd | 1131

beecrowd | 1131

# Grenais

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

The Federação Gaúcha de Futebol invited you to write a program to present a statistical result of several GRENAIS. Write a program that read the number of goals scored by Inter and the number of goals scored by Gremio in a GRENAL. Write the message "Novo grenal (1-sim 2-nao)" and request a response. If the answer is 1, two new numbers must be read (another input case) asking the number of goals scored by the teams in a new departure, otherwise the program must be finished, printing:

- How many GRENAIS were part of the statistics.
- The number of victories of Inter.
- The number of victories of Gremio.
- The number of Draws.
- A message indicating the team that won the largest number of GRENAIS (or the message: "Não houve vencedor" if both team won the same quantity of GRENAIS).

## Input

The input contains two integer values​​, corresponding to the goals scored by both teams. Then there is an integer (1 or 2), corresponding to the repetition of the algorithm.

## Output

After each reading of the goals it must be printed the message "Novo grenal (1-sim 2-nao)". When the program is finished, the program must print the statistics as the example below.

 Input Sample Output Sample 3 2 1 2 3 1 3 1 2 Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) 3 grenais Inter:2 Gremio:1 Empates:0 Inter venceu mais

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include<bits/stdc++.h>

using namespace std;

int main(){
int grenais = 0;
int inter = 0;
int gremio = 0;
int empates = 0;
while (1)
{
int i, g;
cin >> i >> g;
grenais += 1;
if (i > g)
{
inter += 1;
}
else if (i  <  g)
{
gremio += 1;
}
else
{
empates += 1;
}
cout << "Novo grenal (1-sim 2-nao)" << endl;
int n;
cin >> n;
if (n == 2)
{
break;
}
}
cout << grenais << " grenais" << endl;
cout << "Inter:" << inter << endl;
cout << "Gremio:" << gremio << endl;
cout << "Empates:" << empates << endl;
if (inter > gremio)
{
cout << "Inter venceu mais" << endl;
}
else if (inter  <  gremio)
{
cout << "Gremio venceu mais" << endl;
}
else
{
cout << "Nao houve vencedor" << endl;
}

return 0;
}
``````
Copy The Code &

Input

cmd
3 2 1 2 3 1 3 1 2

Output

cmd
Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) 3 grenais Inter:2 Gremio:1 Empates:0 Inter venceu mais

### #2 Code Example with Java Programming

```Code - Java Programming```

``````
import java.io.IOException;
import java.util.Scanner;

public class Main{
public static void main(String[] args) throws IOException{
Scanner input = new Scanner(System.in);
int grenais = 0;
int inter = 0;
int gremio = 0;
int empates = 0;
while (true)
{
int i = input.nextInt();
int g = input.nextInt();
grenais += 1;
if (i > g)
{
inter += 1;
}
else if (i  <  g)
{
gremio += 1;
}
else
{
empates += 1;
}
System.out.println("Novo grenal (1-sim 2-nao)");
int n = input.nextInt();
if (n == 2)
{
break;
}
}
System.out.printf("%d grenais\nInter:%d\nGremio:%d\nEmpates:%d\n", grenais, inter, gremio, empates);
if (inter > gremio)
{
System.out.println("Inter venceu mais");
}
else if (inter  <  gremio)
{
System.out.println("Gremio venceu mais");
}
else
{
System.out.println("Nao houve vencedor");
}
}
}

``````
Copy The Code &

Input

cmd
3 2 1 2 3 1 3 1 2

Output

cmd
Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) 3 grenais Inter:2 Gremio:1 Empates:0 Inter venceu mais

### #3 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
// var lines = input.split('\n');
var sep = [' ', '\n'];
// console.log(separators.join('|'));
var line = input.split(new RegExp(sep.join('|'), 'g'));

var grenais = 0;
var inter = 0;
var gremio = 0;
var empates = 0;

while (true)
{
var i = parseInt(line.shift());
var g = parseInt(line.shift());
grenais += 1;
if (i > g)
{
inter += 1;
}
else if (i  <  g)
{
gremio += 1;
}
else
{
empates += 1;
}
console.log("Novo grenal (1-sim 2-nao)");
var n = parseInt(line.shift());
if (n == 2)
{
break;
}
}
console.log("%d grenais", grenais);
console.log("Inter:%d", inter);
console.log("Gremio:%d", gremio);
console.log("Empates:%d", empates);
if (inter > gremio)
{
console.log("Inter venceu mais");
}
else if (inter  <  gremio)
{
console.log("Gremio venceu mais");
}
else
{
console.log("Nao houve vencedor");
}
``````
Copy The Code &

Input

cmd
3 2 1 2 3 1 3 1 2

Output

cmd
Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) 3 grenais Inter:2 Gremio:1 Empates:0 Inter venceu mais

### #4 Code Example with Python Programming

```Code - Python Programming```

``````
grenais = 0
inter = 0
gremio = 0
empates = 0

while(True):
i, g = map(int, input().split(" "))
grenais += 1
if (i > g):
inter += 1
elif (i < g):
gremio += 1
else:
empates += 1
print("Novo grenal (1-sim 2-nao)")
num = int(input())
if (num == 2):
break

print("%d grenais" % grenais)
print("Inter:%d" % inter)
print("Gremio:%d" % gremio)
print("Empates:%d" % empates)

if (inter > gremio):
print("Inter venceu mais")
elif (inter < gremio):
print("Gremio venceu mais")
else:
print("Nao houve vencedor")
``````
Copy The Code &

Input

cmd
3 2 1 2 3 1 3 1 2

Output

cmd
Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) Novo grenal (1-sim 2-nao) 3 grenais Inter:2 Gremio:1 Empates:0 Inter venceu mais