40分求助
  • 板块题目总版
  • 楼主I_AM_ACer
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/6/13 21:50
  • 上次更新2024/6/14 12:47:53
查看原帖
40分求助
1368992
I_AM_ACer楼主2024/6/13 21:50

有没有大佬帮我看一下为啥错了

#include<bits/stdc++.h>		
using namespace std;
int gcd(int a,int b)
{
	if(a==b)
	{
		return a;
	}
	else if(a>b)
	{
		a-=b;
	}
	else 
	{
		b-=a;
	}
	return gcd(a,b);
}
int lcm(int a,int b)
{
	int temp=a*b;
	temp=temp/gcd(a,b);
	return temp;
}
int main()				
{
	int m,n;			
	cin>>m>>n;	
	cout<<gcd(m,n)<<" ";
	cout<<lcm(m,n);
	return 0;			
}

过样例了但测试时只过了2个测试点

2024/6/13 21:50
加载中...