__gcd 最大公约数
公约数是能够同时整除两个或多个数的正整数。最大公约数指能够同时整除两个或多个整数的最大正整数。
代码示例
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<__gcd(55042,44616);
return 0;
}
输出结果为:26。注意函数名前有两个下划线。
pow 次方
次方表示 n 的 x 次方即 n 乘 x 遍。在 C++ 中,可以使用 pow 函数或位运算实现。
代码示例 1
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<pow(3,11);
return 0;
}
输出:177147
代码示例 2:2 的 23 次方
方法一:使用 pow 函数
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<pow(2,23);
return 0;
}
输出:8.38861e+006
方法二:使用左移运算符
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<(1<<23);
return 0;
}
输出:8388608
注:8.38861e+006 等价于 8388608。左移 x 位相当于乘以 2 的 x 次方。

