Algorithm


Problem Name: beecrowd | 1142

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

beecrowd | 1142

PUM

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

 

Write a program that reads an integer N. This N is the number of output lines printed by this program.

 

Input

 

The input file contains an integer N.

 

Output

 

Print the output according to the given example.

 

 

 

Input Sample Output Sample

7

1 2 3 PUM
5 6 7 PUM
9 10 11 PUM
13 14 15 PUM
17 18 19 PUM
21 22 23 PUM
25 26 27 PUM

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <bits/stdc++.h>

using namespace std;

int main(){
    int num;
    cin >> num;
    int count = 0;
    for (int i = 1; i  < = num * 4; i++){
        if (count == 3){
            cout << "PUM" << endl;
            count = 0;
            continue;
        }
        cout << i << " ";
        count += 1;
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7

Output

x
+
cmd
1 2 3 PUM 5 6 7 PUM 9 10 11 PUM 13 14 15 PUM 17 18 19 PUM 21 22 23 PUM 25 26 27 PUM

#2 Code Example with Java Programming

Code - Java Programming


import java.io.IOException;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws IOException{
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();
        int count = 0;
        for (int i = 1; i  < = num * 4; i++){
            if (count == 3){
                System.out.println("PUM");
                count = 0;
                continue;
            }
            System.out.printf("%d ", i);
            count += 1;
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7

Output

x
+
cmd
1 2 3 PUM 5 6 7 PUM 9 10 11 PUM 13 14 15 PUM 17 18 19 PUM 21 22 23 PUM 25 26 27 PUM

#3 Code Example with Javascript Programming

Code - Javascript Programming


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

var num = parseInt(lines.shift());

var count = 0;

for (var i = 1; i  < = num * 4; i++){
    if (count === 3){
        console.log("PUM");
        count = 0;
        continue;
    }
    process.stdout.write(i+ " ");
    count += 1;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
7

Output

x
+
cmd
1 2 3 PUM 5 6 7 PUM 9 10 11 PUM 13 14 15 PUM 17 18 19 PUM 21 22 23 PUM 25 26 27 PUM

#4 Code Example with Python Programming

Code - Python Programming


num = int(input())

count = 0

for i in range(1, (num * 4) + 1):
    if (count == 3):
        print("PUM")
        count = 0
        continue
    print(i, end=" ")
    count += 1
Copy The Code & Try With Live Editor

Input

x
+
cmd
7

Output

x
+
cmd
1 2 3 PUM 5 6 7 PUM 9 10 11 PUM 13 14 15 PUM 17 18 19 PUM 21 22 23 PUM 25 26 27 PUM
Advertisements

Demonstration


Previous
#1140 Beecrowd Online Judge Solution 1140 Flowers Flourish from France Solution in C, C++, Java, Js and Python
Next
#1143 Beecrowd Online Judge Solution 1143 Squared and Cubic Solution in C++, Java, Js and Python