It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.

Aladdin was about to enter to a magical cave, led by the evil sorcerer who disguised himself as Aladdin's uncle, found a strange magical flying carpet at the entrance. There were some strange creatures guarding the entrance of the cave. Aladdin could run, but he knew that there was a high chance of getting caught. So, he decided to use the magical flying carpet. The carpet was rectangular shaped, but not square shaped. Aladdin took the carpet and with the help of it he passed the entrance.

Now you are given the area of the carpet and the length of the minimum possible side of the carpet, your task is to find how many types of carpets are possible. For example, the area of the carpet 12, and the minimum possible side of the carpet is 2, then there can be two types of carpets and their sides are: {2, 6} and {3, 4}.

Input

Input starts with an integer T (≤ 4000), denoting the number of test cases.

Each case starts with a line containing two integers: a b (1 ≤ b ≤ a ≤ 1012) where a denotes the area of the carpet and b denotes the minimum possible side of the carpet.

Output

For each case, print the case number and the number of possible carpets.

题意:

给你一个长方形面积和一个最小可能的边长,统计有多少种满足面积相等且边长大于等于最小边长的长方形。

思路:

唯一分解定理:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积N=P1^a1 * P2^a2 * P3^a3 ...... Pn^an;

约数个数求和:(a1+1)(a2+1)(a3+1)…(ak+1)    其中a1、a2、a3…ak是p1、p2、p3,…pk的指数。

比如   12 有   [3 , 4]  [2 , 6]  俩对 , [3 , 4]与[4 , 3]算一对 。 数据范围是1e12 , 所以我们可以打表1e6内的素数,然后求出n以内的因子个数,再减去1 ~ a之间可以整除 n 的个数 ,就是答案。

因为我们打表的素数范围是1e6 , 所以如果一个数是超过1e6的素数  或者比如1e12 , 那么1e2我们就可以找到但是1e10超过了范围找不到 , 所以这里有个判断:

	if(n > 1)
	sum *= 2;
	return sum;

大概也就没什么坑点了

贴代码:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1008000;
int prime[maxn] , k , vis[maxn];
void Prime()
{
	 k = 0;
	memset(vis , 0 , sizeof(vis));
	for(int i = 2 ; i < maxn ; i++)
	{
		if(!vis[i])
		{
			prime[k++] = i;
			for(int j = 2 ; i * j < maxn ; j++)
			{
				vis[i*j] = 1;
			} 
		}
	}
}
ll solve(ll n)//K素数个数 
{
	ll sum = 1;
	for(int i = 0 ; i < k && prime[i] * prime[i] <= n ; i++)
	{
		if(n % prime[i] == 0)
		{
			int ans = 0;
			while(n % prime[i] == 0)
			{
				ans++;
				n /= prime[i];
			}
			sum *= (1+ans);
		}
		
	}
	if(n > 1)
	sum *= 2;
	return sum;
}
int main()
{
	int T  , t =  1;
	
	cin >> T;
	Prime();
	while(T--)
	{
		ll a , b;
		cin >> a >> b;
		if(a <= b* b)
		{
			printf("Case %d: 0\n" , t++);
			continue;
		}
		ll num = solve(a);
		num /= 2;
		for(int i = 1 ; i < b ; i++)
		{
			if(a % i == 0)
			{
				num--;
			}
		}
		printf("Case %d: %lld\n" , t++ , num);
	}
	return 0;
 }