Sdut the monkey to the Peach

Source: Internet
Author: User
The monkey divided the peach Time limit:1000ms Memory limit:65536k in doubt. Dot here ^_^ Title DescriptionThe old monkey worked hard for a lifetime, leaving a huge fortune for the few monkeys--a whole bunch of peaches. The old monkey decided to give the peaches to the little monkeys.

The first monkey came, and it divided the peaches into five piles, as many as five, but one more. It left one of the rest to the old monkey and took one of the piles.

The second monkey comes, it divides the peach into five piles, five piles as many, but one more. It left an extra one for the old monkey, and took a bunch of them by himself.
Later the little monkeys did so. The last remaining peaches are all left to the old monkeys.

Here are n little monkeys, please write a program to calculate how many peaches at the beginning, and the last old monkeys can get at least a few peaches. inputThe input includes multiple sets of test data.
Each set of test data includes an integer n (1≤n≤20).
The input ends at 0 and the line is not processed. OutputEach set of test data corresponds to one row of output.
Includes two integers, a, B.
Represents the minimum number of peaches to start with, and the minimum number of peaches the old monkeys can get at the end. Sample Input
5
1
0
Sample Output
3121 1025
1 1
Tips SourceZjgsu Sample Program
#include <stdio.h>
int main ()
{
    int n,i;
    Long long int sum,l,t;
    while (scanf ("%d", &n)!=eof && N)
    {
        l=1;
        for (I=1; i<n; i++)
            l*=5;
        sum=1+5* (L-1);
        T=sum;
        for (I=1; i<=n; i++)
            t= (t-1)/5*4;
        printf ("%lld%lld\n", sum,t+n);
    }
    return 0;
}


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.