您的位置:首页 > 其它

高精度 hdu 2940 Hex Factorial

2016-08-11 22:55 281 查看
直接暴力打表,也可以在代码外打表复制粘贴

#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int BIT = 16;
struct BIGint{
int bit[200];
void MEMset(){
memset(bit,0,sizeof(bit));
bit[1] = 1;
}
void multiply(int n){
int tmp;
for (int i = 1;i < 200;++i)
bit[i] *= n;

for (int i = 1;i < 200;++i)
if (tmp = bit[i] / BIT){
bit[i] %= BIT;
bit[i+1] += tmp;
}
}
int CountZore(){
int i = 199,ans(0);
while( !bit[i--] );
while(i) if(!bit[i--])ans++;
return ans;
}
}bigInt;
int ans[110];
void init(){
memset(ans,0,sizeof(ans));
bigInt.MEMset();
for (int i = 2;i <= 101;++i){
bigInt.multiply(i);
ans[i] = bigInt.CountZore();
}
}

int main ()
{
init();
int n;
while(~scanf("%d",&n) && n >= 0)
printf("%d\n",ans
);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  算法 acm