Algorithm


Problem Name: beecrowd | 1173

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

Array fill I

 

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read a number and make a program which puts this number in the first position of an array N[10]. In each subsequent position, put the double of the previous position. For example, if the input number is 1, the array numbers ​​must be 1,2,4,8, and so on.

 

Input

 

The input contains an integer number V (V < 50).

 

Output

 

Print the stored number of each array position, in the form "N[i] = X", where i is the position of the array and x is the stored number at the position i. The first number for X is V.

 

 

 

Input Sample Output Sample

1

N[0] = 1
N[1] = 2
N[2] = 4
...

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int a;
    cin >> a;
    for(int i = 0; i  <  10; i++){
        cout << "N[" << i << "] = " << a << "\n";
        a = a + a;
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1

Output

x
+
cmd
N[0] = 1 N[1] = 2 N[2] = 4 ...

#2 Code Example with Javascript Programming

Code - Javascript Programming


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

let a = Number(lines.shift());
for(var i = 0; i  <  10; i++){
    console.log(`N[${i}] = ${a}`)
    a = a + a;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1

Output

x
+
cmd
N[0] = 1 N[1] = 2 N[2] = 4 ...

#3 Code Example with Python Programming

Code - Python Programming


a = int(input())
for i in range(0,10):
    print(f'N[{i}] = {a}')
    a = a + a
Copy The Code & Try With Live Editor

Input

x
+
cmd
1

Output

x
+
cmd
N[0] = 1 N[1] = 2 N[2] = 4 ...
Advertisements

Demonstration


Previous
#1172 Beecrowd Online Judge Solution 1172 Array Replacement I Solution in C++, Java, Js and Python
Next
#1174 Beecrowd Online Judge Solution 1174 Array Selection I Solution in C++, Java, Js and Python