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 |
神马整数拆分,dfs就能水过#include <stdio.h> int m,n; int ans; void dfs(int left,int index,int min) { if(index==n) { if(left==0) ans++; return; } for(int i=min;i<=left;i++) dfs(left-i,index+1,i); } int main() { int t; scanf("%d",&t); while(t--) { ans=0; scanf("%d %d",&m,&n); dfs(m,0,0); printf("%d\n",ans); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator