记录编号 128533 评测结果 AAAAAAAAAA
题目名称 [NOIP 2001]最大公约数和最小公倍数问题 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2014-10-17 20:47:17 内存使用 0.29 MiB
显示代码纯文本
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <vector>
#include <queue>

#define maxn ((int)1e5 + 4)
#if defined DEBUG
FILE *in = fopen("test", "r");
#define out stdout
#else
FILE *in = fopen("gcdpro.in", "r");
FILE *out = fopen("gcdpro.out", "w");
#endif
using namespace std;
inline void getint(int &x){
	char c = fgetc(in);
	while(!isdigit(c)) c = fgetc(in);
	x = c - '0';
	while(isdigit(c = fgetc(in)))x = x * 10 - '0' + c;
}

/*===========================================*/
int X0, Y0;
typedef long long LL;
LL mul;
inline LL gcd(LL x, LL y){
	if(x == 0)return y;
	return gcd(y % x, x);
}
int main(){
	getint(X0), getint(Y0);
	mul = (LL)X0 * Y0;
	int i, m, ans = 0, P, Q, t;
	m = Y0 / X0;
	for(P = X0;P <= Y0;P += X0){
		if(mul % P)continue;
		Q = mul / P;
		if(Q % X0)continue;
		if(gcd(P, Q) != X0)continue;
		++ans;
	}
	fprintf(out, "%d\n", ans);
	return 0;
}