数论
唯一分解定理
(1)一个大于1的正整数N, 如果它的标准分解式为:
那么它的正因数个数为:
(2)它的全体正因数之和为:
Aladdin and the Flying Carpet
给一对数字 a,b ,a是一个长方形的面积,问有多少种整数的边的组合可以组成面积为a的长方形,要求最短的边不得小于b
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.
Sample Input
2
10 2
12 2
Sample Output
Case 1: 1
Case 2: 2
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 10;
int primes[N], cnt;
bool st[N];
ll num, tmp;
void get_primes()
{
for(int i = 2; i <= 1000010; i ++)
{
if(!st[i]) primes[cnt ++] = i;
for (int j = 0; primes[j] <= 1000010 / i; j++) {
st[primes[j] * i] = true;
if(i % primes[j] == 0) break;
}
}
}
void cal()
{
for(int i = 0; i < cnt && primes[i] <= sqrt(tmp); i ++)
{
int cc = 0;
while(tmp % primes[i] == 0)
{
cc ++;
tmp /= primes[i];
}
num *= (cc + 1);
}
if(tmp > 1)
num *= 2;
}
int main()
{
int t;
scanf("%d", &t);
int Case = 0;
get_primes();
while(t --){
ll n, m;
scanf("%lld%lld", &n, &m);
if(n < m * m) printf("Case %d: 0\n", ++Case);
else{
num = 1;
tmp = n;
cal();
num /= 2;
for(int i = 1; i < m; i ++)
if(n % i == 0)
num --;
printf("Case %d: %d\n", ++Case, num);
}
}
}