Copying code
Practice
3.9 (15 votes)
Basic math
Algorithms
Mathamatics
Math
Problem
95% Success 2795 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Y has \(n\) lines of code and want to move the \(n\)th line of code to the \(i\)th line of code.
Y can use two methods for this work:
- First, Y can press Ctr + x (two keys) and cut the \(n\)th line of code, then move the cursor to the \(i\)th line pressing up key \(n-i\) times and then paste the \(n\)th line using Ctr + v (two keys).
- Second, Y can press Ctr + up (two keys) \(n-i\) times.
What is the minimum number of keys that Y has to press?
Input
The only line of input is \(n\) and \(i\) separated by space.
\(1 \leq i \leq n \leq 10^9\)
Output
A single line, the minimum number of keys that Y has to press to do the job.
Submissions
Please login to view your submissions
Similar Problems
Points:10
23 votes
Tags:
Very-EasyMathematicsBasic MathSimple-mathMathematics
Points:10
16 votes
Tags:
Very-EasyVery Easy
3.Guess
Points:10
4 votes
Tags:
Very-Easy
Editorial