Algorithm
Problem Name: beecrowd | 1564
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1564
Brazil World Cup
By Gabriel Dalalio, ITA Brazil
Timelimit: 1
Brazil is the country hosting the world cup this year. However, there are many people protesting against the government. In social networks you can see people saying the world cup will not happen.
But these rumors that there will be no world cup are totally false, president Dilma Rousseff has warned: the world cup will happen, and if someone complains about it, we will host again!
Input
The input contains several test cases and ends with EOF. Each test case consists of a line containing a number N of complaints about the world cup forwarded to the president (0 ≤ N ≤ 100).
Output
For each test, the output consists of one line saying "vai ter copa!" if there is no complaints for president. If there are complaints, the output should say "vai ter duas!".
Sample Input | Sample Output |
0 1 0 2 100 0 |
vai ter copa! vai ter duas! vai ter copa! vai ter duas! vai ter duas! vai ter copa! |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
int main ()
{
int complaints{};
while (std::cin >> complaints)
{
std::string cup{ complaints ? "duas" : "copa"};
std::cout << "vai ter " << cup << "!\n";
}
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
let dilma = lines.shift();
while(lines.length != 0){
if(dilma == 0){
console.log("vai ter copa!");
}
else{
console.log("vai ter duas!");
}
dilma = lines.shift();
}
Copy The Code &
Try With Live Editor
Input
Output