1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
#include<bits/stdc++.h> #define maxn 1000 using namespace std; struct Ln{ int val[maxn]; int operator [](const int &ref)const{ return val[ref]; } inline void Lin(){ char S[maxn]; scanf("%s",S); memset(val,0,sizeof(val)); int lenS=strlen(S); val[0]=lenS; for(int i=lenS-1,j=1;i>=0;i--,j++) val[j]=S[i]-'0'; } inline void StrIn(char *S){ memset(val,0,sizeof(val)); int lenS=strlen(S); val[0]=lenS; for(int i=lenS-1,j=1;i>=0;i--,j++) val[j]=S[i]-'0'; } inline void Lout(){ for(int i=val[0];i>=1;i--) putchar(val[i]+'0'); } bool operator ==(const Ln &obj)const{ if(val[0]!=obj[0]) return false; for(int i=1;i<=val[0];i++) if(val[i]!=obj[i]) return false; return true; } bool operator <(const Ln &obj)const{ if(val[0]>obj[0]) return false; if((*this)==obj) return false; if(val[0]<obj[0]) return true; for(int i=val[0];i>=1;i--){ if(val[i]>obj[i]) return false; if(val[i]<obj[i]) return true; } return true; } bool operator >(const Ln &obj)const{ Ln cmp=*this; if(cmp < obj || cmp == obj) return false; return true; } Ln operator +(const Ln &obj)const{ Ln cmp; memset(cmp.val,0,sizeof(cmp.val)); int pos=max(val[0],obj[0]),add=0; for(int i=1;i<=pos;i++){ cmp.val[i]=val[i]+obj[i]+add; add=cmp.val[i]/10; cmp.val[i]=cmp.val[i]%10; } if(add>0) cmp.val[++pos]=add; cmp.val[0]=pos; return cmp; } Ln operator -(const Ln &obj)const{ Ln cmp; memset(cmp.val,0,sizeof(cmp.val)); int pos=val[0],rent=0; for(int i=1;i<=pos;i++){ cmp.val[i]=val[i]-obj[i]-rent; if(cmp.val[i]<0) {cmp.val[i]+=10;rent=1;} else rent=0; } while(cmp.val[pos]==0 && pos>1) pos--; cmp.val[0]=pos; return cmp; } Ln operator *(const int &obj)const{ Ln cmp; memset(cmp.val,0,sizeof(cmp.val)); int pos=val[0]; long long add=0; for(int i=1;i<=pos;i++){ cmp.val[i]=val[i]*obj+add; add=cmp.val[i]/10; cmp.val[i]=cmp.val[i]%10; } while(add>0){ cmp.val[++pos]=add%10; add/=10; } while(cmp.val[pos]==0 && pos>1) pos--; cmp.val[0]=pos; return cmp; } Ln operator *(const Ln &obj)const{ Ln cmp; memset(cmp.val,0,sizeof(cmp.val)); int pos=val[0]+obj[0]; for(int i=1;i<=val[0];i++){ for(int j=1;j<=obj[0];j++){ cmp.val[i+j-1]+=val[i]*obj[j]; cmp.val[i+j]+=cmp.val[i+j-1]/10; cmp.val[i+j-1]=cmp.val[i+j-1]%10; } } while(cmp.val[pos]==0 && pos>1) pos--; cmp.val[0]=pos; return cmp; } Ln operator /(const int &obj)const{ Ln cmp; memset(cmp.val,0,sizeof(cmp.val)); int pos=val[0],div=0; for(int i=pos;i>=1;i--){ cmp.val[i]=(div*10+val[i])/obj; div=(div*10+val[i])%obj; } while(cmp[pos]==0 && pos>1) pos--; cmp.val[0]=pos; return cmp; } int operator %(const int &obj)const{ int pos=val[0],div=0; for(int i=pos;i>=1;i--) div=(div*10+val[i])%obj; return div; } Ln operator /(const Ln &obj)const{ Ln cmp,t_cmp; memset(cmp.val,0,sizeof(cmp.val)); memset(t_cmp.val,0,sizeof(t_cmp.val)); int pos=val[0]; cmp.val[0]=1;cmp.val[1]=0; t_cmp=cmp; if((*this)<obj) return cmp; for(int i=pos;i>=1;i--){ t_cmp=t_cmp*10; t_cmp.val[1]=val[i]; int k=0; while(t_cmp>obj || t_cmp==obj) { t_cmp=t_cmp-obj; k++; } cmp.val[i]=k; } while(cmp.val[pos]==0 && pos>1) pos--; cmp.val[0]=pos; return cmp; } Ln operator %(const Ln &obj)const{ Ln t_cmp; memset(t_cmp.val,0,sizeof(t_cmp.val)); int pos=val[0]; t_cmp.val[0]=1;t_cmp.val[1]=0; if((*this)<obj) return (*this); for(int i=pos;i>=1;i--){ t_cmp=t_cmp*10; t_cmp.val[1]=val[i]; while(t_cmp>obj || t_cmp==obj) t_cmp=t_cmp-obj; } return t_cmp; } }; Ln f[505]={{1,1}}; int n; void solve(){ f[1]=f[0]; for(int i=2;i<=n;i++){ f[i]=(f[i-1]*(4*i-2))/(i+1); } f[n].Lout(); } int main(){ scanf("%d",&n); solve(); return 0; }
|