Shadow97 @ 2024-12-14 11:01:34
#include <bits/stdc++.h>
using namespace std;
long long gcd (long long m,long long n)
{
long long r=m%n;
for (int i=1;i<=m;i++)
{
if (r!=0)
{
m=n;n=r;
r=m%n;
}
}
if (r==0)
return n;
}
int main()
{
long long m,n;
cin>>m>>n;
cout<<gcd(m,n)<<endl;
return 0;
}
by craftmine @ 2024-12-14 11:07:53
用STL的__gcd(a,b)
by Shadow97 @ 2024-12-14 11:08:52
@craftmine....什么意思(STL是什么。。。)
by craftmine @ 2024-12-14 11:11:09
不用管,你把你自己的gcd函数删除,然后把gcd(m,n)
改成__gcd(m,n)
by craftmine @ 2024-12-14 11:11:53
还有用int够了,题目范围10^9
by Shadow97 @ 2024-12-14 11:25:12
@craftmineOKOK,过来,谢谢大佬
by craftmine @ 2024-12-14 11:27:08
这个东西求最大公约数很方便的
by Shadow97 @ 2024-12-14 11:51:13
@craftmineYES,长这么大还没见过这个函数
by craftmine @ 2024-12-14 11:52:59
@Shadow97 我关注你了
by Shadow97 @ 2024-12-14 12:16:29
@craftmine弱弱问一句,大佬是玩网易还是国际??
by craftmine @ 2024-12-14 12:31:10
MC吗?我玩离线的(MC启动器PCL,还有一种我不用的HMCL)