70分WA求助
查看原帖
70分WA求助
662037
_Jonny_404楼主2022/8/12 12:48

代码:

#include<bits/stdc++.h>
using namespace std;

int gcd(int x,int y){
	if(x==y) return x;
	return gcd(min(x,y),max(x,y)-min(x,y));//求最大公约数
}

int bcd(int x,int y){
	int s=gcd(x,y);
	return s*(x/s)*(y/s);//求最小公倍数
}
int ans;
int main(){
	int a,b;
	cin >> a >> b;
	for(int i=1;i<=1500;i++)
		for(int j=1;j<=1500;j++)
			if(gcd(i,j)==a&&bcd(i,j)==b)
				ans++;
	cout<< ans;//枚举
	return 0;
}

没有TLE{\color{Blue}TLE},但是有WA{\color{red}WA}
7个AC{\color{green}AC{}},3个WA{\color{red}WA{}} 7070分求助。

2022/8/12 12:48
加载中...