博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Avito Cool Challenge 2018-A. Definite Game(思维题)
阅读量:4449 次
发布时间:2019-06-07

本文共 1686 字,大约阅读时间需要 5 分钟。

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 nn equals 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 22is a divisor of 88.

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

题意:你可以选小于n的数x,并且这个数不能是n的约数,可以不选,然后n=n-x,然后在进行,直到最小的数。

题解:

我们可以通过直接选n-1,就得到了最小的1,但是要考虑2的情况,因为1是2的约数,故2的时候最小为2

代码非常简单

#include
#include
#include
#include
using namespace std;int main(){ int n; cin>>n; if(n==2) { cout<<2<

 

 

转载于:https://www.cnblogs.com/Staceyacm/p/10781916.html

你可能感兴趣的文章
二分图匹配
查看>>
NoSQL现状
查看>>
在ASP.NET页面中实现数据饼图
查看>>
在WPF中自定义控件(3) CustomControl (下)
查看>>
C# 验证识别基类
查看>>
用bat 删除当前文件夹下的某类文件
查看>>
先序遍历和后序遍历构建二叉树
查看>>
linux xorddos样本分析1
查看>>
【数论】-素数问题整理
查看>>
提高你的Java代码质量吧:正确使用String、StringBuffer、StringBuilder
查看>>
[happyctf]部分writeup
查看>>
HDU 1195 Open the Lock(BFS)
查看>>
Struts2的crud
查看>>
java上传文件
查看>>
大学生对技术网站需求的调查问卷结果分析
查看>>
测试一
查看>>
vertx的HttpServer模块
查看>>
as3事件流机制彻底理解
查看>>
Selenium webdriver操作日历控件
查看>>
Pascal程序练习-与7无关的数
查看>>