Skip to content

Commit 42673fe

Browse files
Berland Poker
1 parent f5b01c6 commit 42673fe

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

1359/A/Main.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
Scanner sc = new Scanner(System.in);
6+
7+
int t = sc.nextInt();
8+
for (int tc = 0; tc < t; ++tc) {
9+
int n = sc.nextInt();
10+
int m = sc.nextInt();
11+
int k = sc.nextInt();
12+
13+
System.out.println(solve(n, m, k));
14+
}
15+
16+
sc.close();
17+
}
18+
19+
static int solve(int n, int m, int k) {
20+
int first = Math.min(m, n / k);
21+
int second = (m - first + k - 2) / (k - 1);
22+
23+
return first - second;
24+
}
25+
}

0 commit comments

Comments
 (0)