LCC/Moose '19 Contest 1 S5 - Division Tests

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

A division test for a number K is a simple algorithm for checking some number is divisible by K. The most well-known division tests are those for two: a number is divisible by two if its last digit is even; and for three: three divides a number if and only if three divides the sum of its digits.

Rosalina has learned a division test for all the numbers up to N. She now wonders how useful this skill is. Specifically, she wants to know how many numbers less than or equal to M are divisible by some number less than or equal to N, since for those numbers Rosalina can successfully apply a division test.

Input Specification

The input contains two integers N, M (1 \le N \le 50, 1 \le M \le 10^{18}).

For 20 of 100 points, M \le 10^6.

For an additional 20 of 100 points, N\le 10.

Output Specification

Output the number of numbers less than or equal to M which are divisible by a number greater than 1 and less than or equal to N.

Sample Input 1

2 10

Sample Output 1

5

Sample Input 2

6 18

Sample Output 2

13

Comments

There are no comments at the moment.