POJ 1644 put Apple recursive recursion

Source: Internet
Author: User
<span id="Label3"></p> <table border="0" width="100%" background="http://poj.org/images/table_back.jpg" style="font-family:Simsun"> <tbody> <tr> <td>Put the Apples <table align="center"> <tbody> <tr> <td>time <strong>Limit:</strong> 1000MS</td> <td width="10px"></td> <td><strong>Memory Limit:</strong> 10000K</td> </tr> <tr> <td><strong>Total Submissions:</strong> 28356</td> <td width="10px"></td> <td><strong>Accepted:</strong> 17939</td> </tr> </tbody> </table><p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Description</p></p>Put m the same apples on n the same plate, allow some plates to be empty, ask how many different ways? (denoted by K) 5,1,1 and 1,5,1 are the same kind of sub-method.<p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Input</p></p>The first line is the number of test data T (0 <= t <= 20). Each of the following lines contains two integers m and n, separated by a space. 1<=m,n<=10.<p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Output</p></p>For each set of data entered M and n, the corresponding K is output in one LINE.<p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Sample Input</p></p><pre class="sio" style="font-family:‘Courier New‘,Courier,monospace; font-size:12pt"><pre class="sio" style="font-family:‘Courier New‘,Courier,monospace; font-size:12pt">17 3</pre></pre><p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Sample Output</p></p><pre class="sio" style="font-family:‘Courier New‘,Courier,monospace; font-size:12pt"><pre class="sio" style="font-family:‘Courier New‘,Courier,monospace; font-size:12pt">8</pre></pre><p class="pst" style="font-size:18pt; font-weight:bold; color:blue"><p class="pst" style="font-size:18pt; font-weight:bold; color:blue">Source</p></p><span class="__cf_email__" data-cfemail="cda1bab58d9d8287"><span class="__cf_email__" data-cfemail="cda1bab58d9d8287">[email protected]</span></span></td> </tr> </tbody> </table><p><p>AC code:</p></p><p><p></p></p><pre name="code" class="cpp"><pre name="code" class="cpp">#include <iostream>using namespace Std;int dg (int m,int n) { if (m<0) return 0; If (m==0| | N==1) return 1; return DG (m-n,n) +DG (m,n-1);} int main () { int t; int a, b; cin>>t; While (t-- ) { cin>>a>>b; COUT<<DG (b) << ' \12 '; } Return 0;}</pre></pre><br><br><p><p></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>POJ 1644 put Apple recursive recursion</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.