#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a,int b){
if(b == 0) return a;
else return gcd(b,a%b);
}
int main() {
int a,b;
cin >> a >> b;
cout << __gcd(a,b) << " " << a*b / __gcd(a,b);
}
#include <numeric> // gcd 和 lcm
#include <iostream>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
cout << gcd(a,b) << " " << lcm(a,b);
}
C
__gcd
是帮助编译器的,不是帮你刷题的。C17中可以这样写:++
怎么变成下划线了谢谢,学到了😊
__gcd()函数是内置于algorithm头文件中的函数,主要是用于求两个数的最大公约数
https://www.cnblogs.com/Staceyacm/p/10010100.html
我看的这里得
我有标准库文档:https://zh.cppreference.com/w/cpp/language/identifiers在任何地方有
__
的标识符被保留(被保留就是人家标准库用的,你别用)注明一下,防止人家的低配版编译器不通过来举报
👍很好