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 ...
随机推荐
- POJ 2096 Collecting Bugs:期望dp
题目链接:http://poj.org/problem?id=2096 题意: 有一个程序猿,他每天都会发现一个bug. bug共有n个种类.属于某一个种类的概率为1/n. 有s个子系统,每个bug属 ...
- CC通信软件list
bozokgh0stnanocoredarkcometponydarkcometadwindadzokaecomblacknixbluebananacorigaratdarkcometDRAThuig ...
- spark源码笔记
1.国际化 如添加朋友Friends是英文,可以找着相关的类,并在国际化配置文件中添加key 在项目中全局搜索“Friends”,将得到的结果集全部展开,找到这两个文件: 在国际化配置文件spark_ ...
- Git_学习_04_ 多人协作开发的过程
多人协作的工作模式通常是这样: 1.首先,可以试图用 git push origin branch-name 推送自己的修改: 2.如果推送失败,则因为远程分支比你的本地更新,需要先用 git pul ...
- OpenCV——Skewing
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- Unity-2017.3官方实例教程Space-Shooter(一)
由于初学Unity,写下此文作为笔记,文中难免会有疏漏,不当之处还望指正. Unity-2017.3官方实例教程Space-Shooter(二) 章节列表: 一.从Asset Store中下载资源并导 ...
- Tensorflow知识点学习
1.TensorFlow中Tensor维度理解: (1)对于2维Tensor 0维对应列 1维对应行 (2)维度操作举例: 对于k维的,tf.reduce_sum(x, axis=k-1)的结果是对最 ...
- POJ2828(插队问题)
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 17077 Accepted: 8466 Desc ...
- POJ2253(djkstra求最长最短边)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32257 Accepted: 10396 Descrip ...
- 异常:Error: Aesthetics must either be length one, or the same length as the dataProblems:AData
今天遇到一个异常,代码如下: set.seed(12345) require(ggplot2) AData <- data.frame(Glabel=LETTERS[1:7], A=rnorm( ...