Skip to content

Commit a9ded0f

Browse files
committed
Create 1836B-Astrophysicists.cpp
1 parent f7b7a40 commit a9ded0f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

1836B-Astrophysicists.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <cstdio>
2+
typedef long long ll;
3+
4+
int main(){
5+
6+
long t; scanf("%ld", &t);
7+
while(t--){
8+
ll n, k, g; scanf("%lld %lld %lld", &n, &k, &g);
9+
ll first = (n - 1) * ((g - 1) / 2);
10+
ll last = k * g - first;
11+
if(last < 0){last = 0;}
12+
else{last += g / 2;}
13+
ll saved = (k - (last / g)) * g;
14+
printf("%lld\n", saved);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)