-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path085. Distribute in Circle.py
71 lines (43 loc) · 1.06 KB
/
085. Distribute in Circle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Distribute in Circle
"""
Problem Description
A items are to be delivered in a circle of size B.
Find the position where the Ath item will be delivered if we start from a given position C.
NOTE: Items are distributed at adjacent positions starting from C.
Problem Constraints
1 <= A, B, C <= 108
Input Format
First argument is an integer A.
Second argument is an integer B.
Third argument is an integer C.
Output Format
Return an integer denoting the position where the Ath item will be delivered if we start from a given position C.
Example Input
Input 1:
A = 2
B = 5
C = 1
Input 2:
A = 8
B = 5
C = 2
Example Output
Output 1:
2
Output 2:
4
Example Explanation
Explanation 1:
The first item will be given to 1st position. Second (or last) item will be delivered to 2nd position
Explanation 2:
The last item will be delivered to 4th position
"""
class Solution:
# @param A : integer
# @param B : integer
# @param C : integer
# @return an integer
def solve(self, A, B, C):
x=A-(B-C+1)
y=x%B
return y