原来就是对两个数分别因数分解,然后分别放到两个集合里,求合并后的集合的大小。再求每个数与另一个集合中该数的幂级数之差,如果另一个集合中没有这个数,就相当于这个集合中这个数的幂级数是0,最后把这些差的绝对值相加就是结果。
/*
ID: sdj22251
PROG: calfflac
LANG: C++
*/
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 100000000
#define LOCA
#define PI acos(-1.0)
using namespace std;
bool tag[1000011];
int p[1000011];
int cnt;
void get_prime()
{
cnt = 0;
tag[1] = 1;
for (int i = 2; i < 1000005; i++)
{
if (!tag[i])
p[cnt++] = i;
for (int j = 0; j < cnt && p[j] * i < 1000005; j++)
{
tag[i*p[j]] = 1;
if (i % p[j] == 0)
break;
}
}
}
int main()
{
#ifdef LOCAL
freopen("ride.in","r",stdin);
freopen("ride.out","w",stdout);
#endif
int a, b, i, cas = 0;
get_prime();
while(scanf("%d%d", &a, &b) != EOF)
{
if(a == 0 && b == 0) break;
int ans = 0;
int count = 0;
for(i = 0; i < cnt && (p[i] <= a || p[i] <= b); i++)
{
bool fg1 = false;
bool fg2 = false;
int ct1 = 0;
int ct2 = 0;
if(a % p[i] == 0)
{
fg1 = true;
while(a % p[i] == 0)
{
a /= p[i];
ct1++;
}
}
if(b % p[i] == 0)
{
fg2 = true;
while(b % p[i] == 0)
{
b /= p[i];
ct2++;
}
}
if(fg1 || fg2)
{
count++;
ans += abs(ct1 - ct2);
}
}
printf("%d. %d:%d\n", ++cas, count, ans);
}
return 0;
}