Skip to content

Commit ea6088f

Browse files
committed
chore: add daily leetcode post [2582]递枕头_translated
1 parent 92ea9e3 commit ea6088f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: 2582.Pillow
3+
date: '2024.01.01 0:00'
4+
tags:
5+
- Python
6+
- answer
7+
- math
8+
- simulation
9+
abbrlink: 82e09f92
10+
---
11+
# topic:
12+
13+
14+
[2582.Pillow.md](https://leetcode-cn.com/problems/di-zhen-tou/)
15+
16+
# Thought:
17+
18+
math题,Find a rule,npersonal,interval=n-1,The number of cycles in the crowd= $time // (n-1)$,The number of cycles is2The number of times from scratch,Otherwise, the number of forwards from the back。
19+
20+
21+
22+
# Code:
23+
```python
24+
class Solution:
25+
def passThePillow(self, n: int, time: int) -> int:
26+
if n > time:
27+
return time + 1
28+
if time // (n-1) % 2 == 0:
29+
return time % (n-1) + 1
30+
else:
31+
return n - time % (n-1)
32+
```

0 commit comments

Comments
 (0)