题意:给出N,求LCM(A,B)为N的A和B的对数。
思路:本垃圾暴力拆解…然后一个一个试乘起来是不是等于N。。。
代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define DB puts("**de**")
#define WATCH(a) cout << a << endl
#define REP(i,n) for(int i=0;i<n;++i)
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define CL(a,b) memset(a,b,sizeof(a))
#define LL long long
#define FD(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define pr pair<int,int >
//#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
//const
const int MAXN=1e6+5;
const int INF=0x3f3f3f3f;
//struct
//global
//vector<int> edge[MAXN];
int ti1,ti2,ti3,m,t,ncase;
LL n;
double td1,td2,td3;
char tc1,tc2;
//func
LL gcd(LL a,LL b)
{
while(b^=a^=b^=a%=b);
return a;
}
int main()
{
//freopen("C:\\Users\\inkysakura\\Desktop\\testdata.txt","r",stdin);
while(scanf("%lld",&n),n)
{
vector<LL> fac;
int i,ans=0;
for(i=1;i*i<n;i++)
if(!(n%i)){fac.pb(i);fac.pb(n/i);}
if(i*i==n&&n%i==0)fac.pb(i);
for(i=0;i<fac.size();i++)
for(int j=i;j<fac.size();j++)
if(fac[i]*fac[j]/gcd(fac[i],fac[j])==n)
ans++;
cout << n<< ' '<<ans<<endl;
}
return 0;
}