Algorithm
Problem Name: beecrowd | 3302
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3302
Correct Answer
By Ricardo Martins, Instituto Federal do Sul de Minas Gerais Brazil
Timelimit: 1
Roumes was an above average student. In math tests, he always got a maximum score, getting all the maths right, but his secret wasn't in doing the math correctly. He interpreted what he saw in the environment around him and he could deduce the answers to the questions. You too can be someone special, just like Roumes.
Input
Input consists of several test cases. Each case contains a number N, representing the number of questions. The next N lines show what you saw to get to the answer.
Output
For each question asked, print the word 'resposta', followed by a space, then the question number, a colon, a space and the answer.
Input Samples | Output Samples |
3 10 20 30 |
resposta 1: 10 resposta 2: 20 resposta 3: 30 |
2 40 50 |
resposta 1: 40 resposta 2: 50 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
#include <string.h>
int main() {
int a;
scanf("%d", &a);
for (int contador = 1; contador < = a; contador++) {
int result;
scanf("%d", &result);
printf("resposta %d: %d\n", contador, result);
}
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
for (int contador = 1; contador < = a; contador++) {
int result;
cin >> result;
printf("resposta %d: %d\n", contador, result);
}
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Javascript Programming
Code -
Javascript Programming
const { readFileSync } = require("fs")
const [numTestCases, ...cases] = readFileSync("/dev/stdin", "utf8").split("\n")
function main() {
const responses = cases.slice(0, +numTestCases).map((text, index) => `resposta ${index + 1}: ${text}`)
console.log(responses.join("\n"))
}
main()
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const n = Number(lines[0])
for(let i = 1; i < = n; i += 1) {
console.log(`resposta ${i}: ${lines[i]}`)
}
Copy The Code &
Try With Live Editor
Input
Output