Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
AC了#include<iostream> using namespace std; struct big { int length; char shu[500]; void output() { for(int i=length-1;i>=0;i--) { cout<<(int)shu[i]; } cout<<endl; } }; big mul(int cheng,big bei) { int shu[500]; for(int i=0;i<500;i++) { shu[i]=0; } big ret; int wei=0; for(int j=0;j<bei.length;j++) { int ran=cheng*bei.shu[j]; shu[j]=ran; } for(int j=0;j<500;j++) { int ran=shu[j]; int jin=ran/10; int liu=ran%10; ret.shu[j]=(char)liu; shu[j+1]+=jin; if(shu[j]) { wei=j; } } wei++; ret.length=wei; return ret; } big add(big a,big b) { big ret; if(a.length<b.length) { swap(a,b); } int wei=a.length; int jin=0; for(int i=0;i<b.length;i++) { int ran=a.shu[i]+b.shu[i]+jin; ret.shu[i]=ran%10; jin=ran/10; } for(int i=b.length;i<a.length;i++) { int ran=a.shu[i]+jin; ret.shu[i]=ran%10; jin=ran/10; } if(jin) { wei++; ret.shu[a.length]=jin; } ret.length=wei; return ret; } int main() { big hao[101]; big huai[101]; hao[0].length=1;hao[0].shu[0]=1; hao[1].length=1;hao[1].shu[0]=0; hao[2].length=1;hao[2].shu[0]=0; huai[0].length=1;huai[0].shu[0]=0; huai[1].length=1;huai[1].shu[0]=0; huai[2].length=1;huai[2].shu[0]=1; for(int i=3;i<101;i++) { hao[i].length=huai[i-1].length; hao[i]=huai[i-1]; hao[i].output(); huai[i].length=1;huai[i].shu[0]=0; huai[i]=add(huai[i],mul((i)*(i-1),huai[i-2])); huai[i]=add(mul((i)*(i-1)/2,hao[i-2]),huai[i]); huai[i]=add(mul((i)*(i-1)/2*(i-2),hao[i-3]),huai[i]); } int n; cin>>n; hao[n].output(); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator