Algorithm


Problem Name: beecrowd | 3040

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

The Christmas Tree

 

By Matheus Fabian, URI BR Brazil

Timelimit: 1

Every year, Roberto likes to choose his Christmas tree, he doesn't let anyone choose for him, because he thinks the tree to be beautiful, must meet some conditions, such as height, thickness and number of branches, so he can hang many Christmas decorations on it.

Roberto wants his tree to be at least 200 centimeters tall, but he doesn't want it to be larger than 300 centimeters, or the tree won't fit in his house. As for thickness, he wants his tree to have a trunk that is 50 centimeters in diameter or more. The tree must be 150 branches or greater.

 

Input

 

The first line of input contains an integer N(0 < N ≤ 10000), the number of test cases. The next N lines contain 3 integers each, h, d and g(0 < a, d, g ≤ 5000), the height of the tree in centimeters, its diameter in centimeters, and the amount of tree branches.

 

Output

 

Your task is, for each tree, to print Sim, if it is a tree that Roberto can choose, or Nao, if it is a tree he should not choose.

 

 

 

Input Sample Output Sample

8

200 60 160

150 50 200

300 85 341

110 10 50

450 90 1141

270 40 340

262 51 432

203 60 200

Sim

Nao

Sim

Nao

Nao

Nao

Sim

Sim

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(int argc, char **argv)
{

    int n, h, d, g;

    scanf("%d", &n);

    for (int i = 0 ; i  <  n; ++i)
    {

        scanf("%d %d %d", &h, &d, &g);

        if (h >= 200 && h  < = 300)
            if (d >= 50)
                if (g >= 150)
                {
                    puts("Sim");
                    continue;
                }

        puts("Nao");

    }

    return 0;

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 200 60 160 150 50 200 300 85 341 110 10 50 450 90 1141 270 40 340 262 51 432 203 60 200

Output

x
+
cmd
Sim Nao Sim Nao Nao Nao Sim Sim

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main(void){
    int n, a, d, g;
    bool flag;
    cin >> n;
    while(n > 0){
        cin >> a >> d >> g;
        flag = false;
        if(a >= 200 && a <= 300>{
            if(d >= 50){
                if(g >= 150)
                    flag = true;
            }
        }

        if(flag == true)
            cout << "Sim" << endl;
        else
            cout << "Nao" << endl;
        
        n--;
    }

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

Input

x
+
cmd
8 200 60 160 150 50 200 300 85 341 110 10 50 450 90 1141 270 40 340 262 51 432 203 60 200

Output

x
+
cmd
Sim Nao Sim Nao Nao Nao Sim Sim

#3 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")

const [[numCases], ...trees] = readFileSync("/dev/stdin", "utf8")
	.split("\n")
	.map(tree => tree
		.split(" ", 3)
		.map(Number.parseFloat)
	)

/**
 * @param {number} height
 * @param {number} thickness
 * @param {number} branches
 * @return {boolean}
 */

const validateTree = (height, thickness, branches) => {
	return (
		(height >= 200 && height <= 300)
		&& (thickness >= 50)
		&& (branches >= 150)
	)
}

function main() {

	const responses = trees
		.slice(0, numCases)
		.map(tree => validateTree(...tree) ? "Sim" : "Nao")

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

main()
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 200 60 160 150 50 200 300 85 341 110 10 50 450 90 1141 270 40 340 262 51 432 203 60 200

Output

x
+
cmd
Sim Nao Sim Nao Nao Nao Sim Sim

#4 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const number = parseInt(lines.shift());

for(let i = 0; i  <  number; i++){
  let [a, b, c] = lines.shift().trim().split(" ").map(parseFloat);
  if(b >= 50 && c >= 150 && (200 <= a && a  < = 300)){
    console.log("Sim");
  }
  else{
    console.log("Nao">;
  }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 200 60 160 150 50 200 300 85 341 110 10 50 450 90 1141 270 40 340 262 51 432 203 60 200

Output

x
+
cmd
Sim Nao Sim Nao Nao Nao Sim Sim
Advertisements

Demonstration


Previous
#3039 Beecrowd Online Judge Solution 3039 Santa's Toys Solution in C, C++, Java, Js and Python
Next
#3046 Beecrowd Online Judge Solution 3046 Dominó Solution in C, C++, Java, Js and Python