Time limit:4000ms Memory limit:65536k
Total submit:258 accepted:81
Description
There were a bunch of peaches and n monkeys, and the first monkey divided the peaches into M-piles, and there were 1 left, and it ate the rest and took a bunch. The monkeys in the back also took the same approach as the 1th, and asked n monkeys how many peaches they had left at least after they had done the same thing (assuming that there was at least one peach in each of the remaining piles). And at least how many at the beginning of the pile of peaches.
Input
The input contains two data, separated by a space between the data. The first data for the only number of monkeys N (1≤N≤10), the second data for the heap number of peaches divided by M (2≤m≤7).
Output
The output contains two rows of data, the first row is the number of Peaches left, the second row is the original number of peaches.
Sample Input
3 2
Sample Output
1
15
*/
#include < stdio.h >
#define MAX 100000001
int main (void)
{
Long M,n,end,start;
Long i,j,k;
scanf ("%ld%ld", & N, & M);
for (i = 1; I <= MAX; i + +)
{
for (j = 1, k = i; j <= N; j + +)
{
if ((k * m)% (m-1) = = 0)
{
K = (k * m)/(m-1) + 1;
}
Else
break;
}
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.