KCE_0002-Editorial

GOT
Inception

Setter : harijey
Tester : rohinth_076
Editorialist: harijey

DIFFICULTY:

Easy.

PREREQUISITES:

None

PROBLEM:

Lord Robert Stark the young wolf of Winterfell wants to reach the King’s landing to avenge his father’s death. To invade the King’s landing, he must have enough troops. In order to attain the strength Robert believes that the number of platoons N should be that that each digit of N must be divisible by N for example if he has 128 platoons then 128%1==0,128%2==0 and 128%8==0 so Robert Stark would bring 128 platoons to invade the King’s landing. But Lord Stark cannot bring his entire troop for the invasion. He likes to know his option in this hand. He wants to bring at least min

number of platoons for his invasion plan to succeed.

You are given a number noOfPlatoons return how many possible numbers of platoons shall Lord Stark could take with him to overtake Joffrey Baratheon of King’s landing.

Input Format

  • First line will contain min, minimum number of platoons for his invasion plan
  • Second line will contain noOfPlatoons

Output Format

Print how many possible numbers of platoons shall Lord Stark could take with him

Constraints

  • 1≤min≤10000

  • 1≤noOfPlatoons≤100000

Sample Input

47
85

Sample Output

4

Explanation

48, 55 , 66 ,77 are the possible numbers of platoons in the range 47 to 85

SOLUTION:

import java.io.*;
import java.util.*;
class Solution{
	static Scanner fs  = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
	    int min = fs.nextInt();
        int max = fs.nextInt();
        int ans = 0;
        outer:for(int i=min;i<=max;i++){
            int m = i;
            while(m > 0){
                int r = m%10;
                if(r == 0 || i%r !=0) continue outer;
                m /= 10;
            }
            ans++;
        }
        out.println(ans);
        out.flush();
		
	}
}