今天刷清北的题,连生物必修二纯合子杂合子对数比例计算都用上了【一上来看完题目之后计算样例胡搞】
内心疼痛,找不到正解哭倒在地
内心悲愤无以言表刷波高精阶乘发狂
另外注明29的阶乘为“8841761993739701954543616000000”【Codevs上给的88417 ‘16’ 993739701954543616000000 mmp】
代码如下:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef unsigned long long ull;
const int sz=200000000;
ull a[sz],n;
ull m,la=1;
#define RI register int
inline void read(ull &x)
{
x = 0;
bool flag = 0;
char ch = getchar();
while(ch < '0' || ch > '9')
{if(ch == '-') flag = 1;ch = getchar();}
while(ch >= '0' && ch <= '9')
{x = x * 10 + ch - '0';ch = getchar();}
if(flag)
x *= -1;
}
inline void write(ull x)
{
if(x < 0)
putchar('-'),x *= -1;
if(x / 10)
write(x / 10);
putchar(x % 10 + '0');
}
int main()
{
read(n);
a[1]=1;
for(RI i=1;i<=n;++i)
{
for(RI j=1;j<=la;++j)
{
a[j]*=i;
a[j]+=m;
m=a[j]/10;
a[j]=a[j]%10;
}
while(m>0)
{
la++;
a[la]+=m%10;
m/=10;
}
}
for(RI i=la;i>=1;i--)
write(a[i]);
return 0;
}