Algorithm
Problem Name: beecrowd | 1865
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1865
Mjölnir
By Ricardo Martins, IFSULDEMINAS Brazil
Timelimit: 1
Odin created to Thor the most faithful and powerful possible weapon, Mjolnir hammer. Made of a special mystical ore called Uru and forged in the heart of a star by blacksmiths Gods of Asgard , Brokk and Eitri , blacksmiths legendary.
One day , Thor challenged his friends to see who could raise the Mjölnir .
Write a program that , given a name , and the force in Newtons applied to try to lift the Thunder Hammer , inform the person succeeded in lifting it .
Input
An integer C shall be informed , which is the amount of test cases. Each test case begins with one word , which is the first name of who is trying to raise Mjölnir , and an integer N ( 1 ≤ N ≤ 25000 ), indicating the force applied upward in Newtons to pull the hammer of so try to lift it.
Output
For each test case print a 'Y' character , if the person has managed to raise or 'N' if you have not achieved .
Input Sample | Output Sample |
4 Hulk 5000 Tony 1000 Thor 50 Steve 500 |
N N Y N |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
string s;
for(int i = 0 ; i < n ; i ++){
int a;
cin >> s >> a;
if(s == "Thor")
cout << "Y\n";
else
cout << "N\n";
}
return 0;
}
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');
const number = lines.shift();
let herois = lines.shift().split(" ");
let x = 0;
while(x < number){
if(herois[0] == 'Thor'){
console.log("Y");
}
else{
console.log("N");
}
herois = lines.shift().split(" ");
x++;
}
Copy The Code &
Try With Live Editor
Input
Output