分苹果

  POJ-1664  

  

 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 int solve(int n,int m){
 6     if(n==1 || n==0 || m==1)
 7     return 1;
 8     if (n<m){
 9         return solve(n, n);
10     }
11     else{
12         return     solve(n, m-1)+solve(n-m, m);
13     }
14 }
15 
16 
17 int main(int argc, char *argv[]) {
18     int times;
19     int n,m;
20     cin>>times;
21     while (times--) {
22         cin>>n>>m;
23         cout<<solve(n, m)<<endl;
24     }
25 }

 

posted @ 2019-02-21 14:32  Rohlf  阅读(180)  评论(0编辑  收藏  举报