Avito Cool Challenge 2018-A. Definite Game(思维题)
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<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
if(n==2)
{
cout<<2<<endl;
}
else
{
cout<<1<<endl;
}
return 0;
}
Avito Cool Challenge 2018-A. Definite Game(思维题)的更多相关文章
- Codeforces Avito Code Challenge 2018 D. Bookshelves
Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...
- Avito Cool Challenge 2018
考挂了.. A - Definite Game 直接看代码吧. #include<cstdio> #include<cstring> #include<algorithm ...
- Avito Cool Challenge 2018(div1+2)
A. Definite Game: 题意:输入N,输出最小的结果N-x,其中x不少N的因子. 思路:N=2时,输出2:其他情况输出1:因为N>2时,N-1不会是N的因子. #include< ...
- Avito Cool Challenge 2018 Solution
A. Definite Game 签. #include <bits/stdc++.h> using namespace std; int main() { int a; while (s ...
- Avito Cool Challenge 2018 A. B题解
A. Definite Game 题目链接:https://codeforces.com/contest/1081/problem/A 题意: 给出一个数v,然后让你可以重复多次减去一个数d,满足v% ...
- Avito Code Challenge 2018
第一次打CF,很菜,A了三道水题,第四题好像是是数位DP,直接放弃了.rateing从初始的1500变成了1499,还是绿名,这就很尴尬.之后觉得后面的题目也没有想象的那么难(看通过人数)过两天吧剩下 ...
- Avito Cool Challenge 2018 自闭记
A:n==2?2:1. #include<iostream> #include<cstdio> #include<cmath> #include<cstdli ...
- Avito Cool Challenge 2018 E. Missing Numbers 【枚举】
传送门:http://codeforces.com/contest/1081/problem/E E. Missing Numbers time limit per test 2 seconds me ...
- Avito Cool Challenge 2018 C. Colorful Bricks 【排列组合】
传送门:http://codeforces.com/contest/1081/problem/C C. Colorful Bricks time limit per test 2 seconds me ...
随机推荐
- 一步一步教你简单完成 Android USB开发
项目中有一个新的需求,要求可以连接一个USB体温枪,APP可以从体温枪中读取到体温数据,一番搜寻之后发现一个封装很棒的USB通信库. github地址:usb-serial-for-android 准 ...
- 详解Java异常Throwable、Error、Exception、RuntimeException的区别
在Java中,根据错误性质将运行错误分为两类:错误和异常. 在Java程序的执行过程中,如果出现了异常事件,就会生成一个异常对象.生成的异常对象将传递Java运行时系统,这一异常的产生和提交过程称为抛 ...
- 书写优雅的shell脚本(八)- 日期格式化
1. 将日期格式转为时间戳 获取当前时间:currenttime=`date "+%Y-%m-%d %H:%M:%S"` 结果:2015-04-13 11:15:43 将当前时间转 ...
- hdu-5778 abs(暴力枚举)
题目链接: abs Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Pro ...
- C语言中数据类型和变量
C语言中的数据类型 数据类型的本质,固定大小内存块的别名. 数组名代表数组首元素的地址. 数组首元素的地址,&代表整个数组的地址. 数组数据类型,怎么定义数据数组类型,定义数组类型指针,数组类 ...
- 【LeetCode】091. Decode Ways
题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: ' ...
- BZOJ3127:[USACO2013OPEN]Yin and Yang
浅谈树分治:https://www.cnblogs.com/AKMer/p/10014803.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem. ...
- java计算两个时间相差(天、小时、分钟、秒)
public static Long dateDiff(String startTime, String endTime, String format, String str) { // 按照传入的格 ...
- Ubuntu vim使用
vim安装:apt-get install vim-gtk vim使用:默认启动插入模式,或者按‘I’进入插入模式,退出插入模式按‘esc’,用冒号‘:wq’进行保存退出: 其复制和粘贴是靠鼠标右键中 ...
- zk 09之:Curator之二:Path Cache监控zookeeper的node和path的状态
在实际应用开发中,当某个ZNode发生变化后我们需要得到通知并做一些后续处理,Curator Recipes提供了Path Cache 来帮助我们轻松实现watch ZNode. Path Cache ...