Avito Cool Challenge 2018 A. Definite Game

版权声明:限于博主能力有限,不排除出现错误的地方,希望大佬指出,多多 交流,共同进步。 https://blog.csdn.net/SunPeishuai/article/details/85213761

Chouti was doing a competitive programming competition. However, after having all the problems accepted, he got bored and decided to invent some small games.

He came up with the following game. The player has a positive integer nn. Initially the value of nnequals to vv and the player is able to do the following operation as many times as the player want (possibly zero): choose a positive integer xx that x<nx<n and xx is not a divisor of nn, then subtract xx from nn. The goal of the player is to minimize the value of nn in the end.

Soon, Chouti found the game trivial. Can you also beat the game?

Input

The input contains only one integer in the first line: vv (1≤v≤1091≤v≤109), the initial value of nn.

Output

Output a single integer, the minimum value of nn the player can get.

Examples

input

Copy

8

output

Copy

1

input

Copy

1

output

Copy

1

Note

In the first example, the player can choose x=3x=3 in the first turn, then nn becomes 55. He can then choose x=4x=4 in the second turn to get n=1n=1 as the result. There are other ways to get this minimum. However, for example, he cannot choose x=2x=2 in the first turn because 22 is a divisor of 88.

In the second example, since n=1n=1 initially, the player can do nothing.

题意:

给定一个数,每次可以减去任一个比其小的但不能是他的因子的数(也可以不减),输出最后得到的最小值 。

分析:

任意相邻的两个数一定是互质的数,开始直接就输出了1,wr,漏了一种情况就是当输入的数是 2的时候,因为1是它的一个因子,不能减,所以其他的情况直接输出1当为2时输出2就可以了。

代码:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n==2) printf("2\n");
    else printf("1\n");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/SunPeishuai/article/details/85213761