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 |
Re:brute forceIn Reply To:brute force Posted by:ysjjovo at 2011-03-13 21:01:52 > #include<iostream> > using namespace std; > int ans,curCnt; > int curNumber; > int cnt; > void work(int k,int cur){//k<=cnt-1,cur<=curNumber > if(k==cnt-1){ > if(curNumber>=cur&&curNumber<=cur+9)curCnt++;// ÕâÒ»¾äshit!!! > } > else{ > if(cur+(cnt-k)*9<curNumber)return; > int i; > for(i=0;i<10;i++){ > if(cur+i>curNumber)return; > work(k+1,cur+i); > } > } > } > > int main(){ > int n; > cin>>n; > if(n&1){ > cout<<0<<endl; > return 0; > } > ans=2; > int i; > cnt=n/2; > for(i=1;i<cnt*9;i++){ > curNumber=i; > curCnt=0;//0,max > work(0,0); > ans+=(curCnt*curCnt); > } > cout<<ans<<endl; > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator