Algorithm


Problem Name: beecrowd | 1133

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

beecrowd | 1133

Rest of a Division

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads two integer numbers X and Y. Print all numbers between X and Y which dividing it by 5 the rest is equal to 2 or equal to 3.

Input

The input file contains 2 any positive integers, not necessarily in ascending order.

Output

Print all numbers according to above description, always in ascending order.

Input Sample Output Sample

10
18

12
13
17

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <bits/stdc++.h>

using namespace std;

int main(){
    int x, y;
    cin >> x;
    cin >> y;
    if (x > y){
        int temp;
        temp = x;
        x = y;
        y = temp;
    }
    
    for (int i = x+1; i  <  y; i++){
        if ((i % 5 == 2) || (i % 5 == 3)){
             cout << i << endl;
        }
    }
    
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 18

Output

x
+
cmd
12 13 17

#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 x = input.nextInt();
        int y = input.nextInt();

        if (x > y){
            int temp = x;
            x = y;
            y = temp;
        }

        for (int i = x+1; i  <  y; i++){
            if ((i % 5 == 2) || (i % 5 == 3)){
                System.out.println(i);
            }
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 18

Output

x
+
cmd
12 13 17

#3 Code Example with Javascript Programming

Code - Javascript Programming


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

var x = parseInt(lines.shift());
var y = parseInt(lines.shift());

if (x > y){
    var temp = x;
    x = y;
    y = temp;
}

for (var i = x+1; i  <  y; i++){
    if ((i % 5 == 2) || (i % 5 == 3)){
        console.log(i);
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 18

Output

x
+
cmd
12 13 17

#4 Code Example with Python Programming

Code - Python Programming


x = int(input())
y = int(input())

if (x > y):
    temp = x
    x = y
    y = temp

for i in range(x+1, y):
    if ((i % 5 == 2) or (i % 5 == 3)):
        print(i)
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 18

Output

x
+
cmd
12 13 17
Advertisements

Demonstration


Previous
#1132 Beecrowd Online Judge Solution 1132 Multiples of 13 Solution in C++, Java, Js and Python
Next
#1134 Beecrowd Online Judge Solution 1134 Type of Fuel Solution in C++, Java, Js and Python