Test instructions: Ask for a n! The number of 16 binary representations of 0.
High-precision simulations, or direct java. Here you can give a high-precision template.
#include <cstdio> #include <cstdio> #include <cmath> #include <queue> #include <stack># include<string> #include <cstring> #include <iostream> #include <map> #include <vector># include<algorithm> #include <set> #include <cmath>using namespace std;const int mmax = 10010;const int INF = 0x3fffffff;struct bignum{int Sz; int Num[mmax]; void print () {for (int i=sz-1;i>=0;i--) printf ("%0x", Num[i]); Puts (""); } bignum () {} bignum (int Sz,char *a) {sz=sz; for (int i=0;i<sz;i++) {num[i]=a[sz-1-i]-' 0 '; }} bignum (int sz,int *a) {sz=sz; for (int i=0;i<sz;i++) num[i]=a[i]; } bignum (int x) {sz=0; while (x) {num[sz++]=x%16; x/=16; }} Bignum operator + (const bignum &a) {int Tmp[mmax]; memset (tmp,0,sizeof tmp); int Len=max(SZ,A.SZ); for (int i=0;i<len;i++) {tmp[i]+=num[i]+a.num[i]; TMP[I+1]+=TMP[I]/10; tmp[i]%=10; } return Bignum (len+ (tmp[len]?1:0), TMP); } bignum Operator-(const bignum &a) {int Tmp[mmax]; memset (tmp,0,sizeof tmp); int Len=max (SZ,A.SZ); for (int i=0;i<len;i++) {tmp[i]+=num[i]-a.num[i]; if (tmp[i]<0) {tmp[i+1]-=1; tmp[i]+=10; }} for (int i=len-1;i>=0;i--) {if (Tmp[i]) return Bignum (I+1,TMP); } return Bignum (1,TMP); } bignum operator * (const bignum &a) {int Tmp[mmax]; memset (tmp,0,sizeof tmp); for (int i=0;i<sz;i++) for (int j=0;j<a.sz;j++) {tmp[i+j]+=num[i]*a.num[j]; } for (int i=0;i<sz+a.sz;i++) {tmp[i+1]+=tmp[i]/16; tmp[i]%=16; } for (int i=sz+a.sz-1;i>=0;i--) {if (Tmp[i]) return Bignum (I+1,TMP); } return Bignum (1,TMP); }};int Main () {int n; while (Cin>>n && n>=0) {bignum ans (1); for (int i=1;i<=n;i++) ans=ans*bignum (i); int cnt=0; for (int I=0;i<ans. sz;i++) {if (ans.num[i]==0) cnt++; } printf ("%d\n", CNT); } return 0;}
HDU 2940 Hex factorial (simple high precision)