数学公式
作者:
张耀扬
,
2024-04-14 11:56:49
,
所有人可见
,
阅读 7
$ 第一板块 $ $ 数学公式 $
1. 组合数:$ C_n^m $ = $ n! \over (n-m)! \times m! $
2. 卡特兰数:$ C_n $ = $ {1 \over n + 1} \times C_{2n}^n $(此公式用于求卡特兰数的第$n$项$C_n$)
# include <bits/stdc++.h>
# define sc scanf
# define pr printf
using namespace std;
typedef long long LL;
LL n;
int main(){
sc("%lld", &n);
LL s = sqrt(n);
if(s * s == n){
pr("1\n");
return 0;
}
// 1
for(LL i = 1; i <= n / i; i ++){
LL res = n - i * i;
LL s = sqrt(res);
if(s * s == res){
pr("2\n");
return 0;
}
}
// 2
while(n % 4 == 0) n /= 4;
if(n % 8 == 7){
pr("4\n");
return 0;
}
pr("3\n");
return 0;
}