include "stdafx.h"
// ConsoleApplication12.cpp : 定义控制台应用程序的入口点。
//
#include<iostream>
#include<vector>
using namespace std;
class Apples {
public:
int num = 0;
int getInitial(int n) {
// write code here
int remianApple = 1;
int appleNums = n;
// while(true)
while (true)
{
bool flag = false;
remianApple = appleNums;
int num = n;
// cout << "######### " << appleNums << " ##################" << endl;
while (num!=0) //
{
if (remianApple<= 0)
{
break;
}
else if ( remianApple%n != 1) //不符合要求,每次都不剩下1个苹果
{
break;
}
else {
//循环完毕,找到对应的苹果数目
int getApple = (remianApple - 1) / n;//每次拿走的苹果数目
remianApple = remianApple - getApple-1;
// cout << num << ": " << " getApple:" << getApple << " remianApple:" << remianApple << endl;;
// cout << "num:" << num << endl;
num = num - 1;
}
}
if (num == 0)
{
// cout << "remianApple:" << remianApple << endl;
break;
}
appleNums++;
}
return appleNums;
}
};
int main()
{
Apples apple;
int i;
while (cin>>i)
{
// cout << "共有的苹果:" ;
cout << apple.getInitial(i) << endl;
}
return 0;
}