This page is still under construction.

Parts of this page are still being built. What you see may change.

Quarantine Math

Time limit1.25sMemory limit256 MB

Summary
Given n and m up to 1e9, sum the divisor counts of all positive k with (n mod k) + (m mod k) >= k, using number theory.
Level

Hard8 of 10

Topics
Number theory, Math, Brute force, Implementation
Solved
No attempts yet

Problem

It's quarantine and you're so bored that you decided to dedicate some time to level up your math skills. Unfortunately, yesterday you bumped into a problem you couldn't solve. However, you've dreamt of this problem for the entire night, so maybe today the luck will be on your side?

For given natural numbers nn, mm, let S(n,m)S(n, m) be a set of positive integers such that for every element kk in this set, (n mod k)+(m mod k)≥k(n \bmod k) + (m \bmod k) \ge k, where a mod ba \bmod b is the remainder of aa divided by bb.

The problem asks to compute the value of the following function: F(n,m)=∑_k∈S_(n,m)D(k)F(n, m) = \sum\_{k \in S\_{(n,m)}}{D(k)} where D(x)D(x) is the number of positive divisors of the number xx.

Input

Two natural numbers nn, mm. 1≤n,m≤1091 \le n, m \le 10^9.

Output

One number: the value of the function F(n,m)F(n, m).

Hint

S(4,7)=5,8,9,10,11S(4, 7) = 5, 8, 9, 10, 11, D(5)=2D(5) = 2, D(8)=4D(8) = 4, D(9)=3D(9) = 3, D(10)=4D(10) = 4, D(11)=2D(11) = 2

Examples1

  1. Example 1

    Input
    4 7
    
    Expected output
    15