算术基本定理,又称为正整数的唯一分解定理,即:每个大于1的自然数,若不是本身就是质数,就是可写为2个以上的质数的积,而且这些质因子按大小排列之后,写法仅有一种方式。
n的正因子数的个数sum可以表示为:sum=(1+a1)*(1+a2)*(1+a3)……(1+an);
每一个数n都能被分解为:n=p1^a1*p2^a2*^p3^a3……pn^an(p为素数);
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 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.
For each case, print the case number and the number of possible carpets.
#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<vector> typedef long long ll; using namespace std; const ll m=1e6+14; ll c[m]; vector<ll>v; void cc() { memset(c,1,sizeof c); for(ll i=2; i<m; i++) for(ll j=i*i; j<m; j+=i) c[j]=0; for(ll i=2; i<m; i++) if(c[i])v.push_back(i); } ll ccc(ll x) { ll cccc=1; for(ll i=0; v[i]<x&&i<v.size(); i++) { ll n=0; while(x%v[i]==0) { x/=v[i]; n++; } cccc*=n+1; } if(x>1)cccc*=2; return cccc; } int main() { ll e=1,t; scanf("%lld",&t); cc(); while(t--) { ll x,y; scanf("%lld%lld",&x,&y); if(x<y*y)printf("Case %lld: 0\n",e++); else { ll ccccc=ccc(x)/2; for(ll i=1; i<y; i++) if(x%i==0)ccccc--; printf("Case %lld: %lld\n",e++,ccccc); } } return 0; }