# Weird Elevators

HackWithInfy Problems

#### Problem Statement:

A multi-story building has several floors. Each floor has an elevator. You are given two integers X and Y. The elevators in the building have a system with the following rules.

• From any floor number A, you can only move to the floors numbered A/P, where P is the prime factor of A smaller than a given number M.
• The elevator takes exactly 1 second to move to another floor.
• Only one elevator can move at a time.

Write a program to find the minimum time required to move to a common floor.

Example:

``````Input:
3
20 16 10
100 120 10
160 180 10``````
``````Output:
3 4
3 20
5 20``````

#### Code:

``````import java.util.*;

class Innoskrit {

public static void main(String[] args) {

}
}``````
``````class Innoskrit:
pass

if __name__ == "__main__":
pass``````
``````#include <bits/stdc++.h>
using namespace std;

class Innoskrit {
public:

};

int main() {

} ``````

Output:

#### Innoskrit

We're building a next-level EdTech Startup.