Algorithm
Problem Name: beecrowd | 1759
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1759
Ho Ho Ho
By Lucas Campesatto, beecrowd Brazil
Timelimit: 1
Santa Claus is playing with his elves to entertain them during the Christmas Eve. The game consists of the elves writing numbers on pieces of paper and place on the cap of Santa Claus. After all finished to put the numbers, Santa draws a number and that number is how many "Ho" he should say.
Your job is to help Santa Claus by making a problem that shows all the "Ho" that he should speak given the number drawn.
Input
The input consists of a single integer N (0 < N ≤ 106) representing how many "Ho" will be spoken by Santa.
Output
The output consists of all "Ho" that Santa should speak separated by a space. After the last "Ho" you must present an "!" ending the program.
Input Sample | Output Sample |
5 |
Ho Ho Ho Ho Ho! |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
int main()
{
int times_to_spoke{};
std::cin >> times_to_spoke;
for (int i = 1; i < = times_to_spoke; ++i) {
std::cout << "Ho" << (i == times_to_spoke ? "!\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');
var N = parseInt(lines.shift());
for (let i = 1; i < = N; i++) {
if (i == N) console.log('Ho!');
else process.stdout.write('Ho ');
}
Copy The Code &
Try With Live Editor
Input
Output