-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp1955A.cpp
37 lines (35 loc) · 926 Bytes
/
p1955A.cpp
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
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t-- > 0){
int n, a, b, count = 0;
cin >> n >> a >> b;
if(n == 1 && a < b){
cout << a << endl;
}
else {
bool flag = (a * 2) < b;
while(n > 0){
if(n > 1){
if(flag){
cout << a * n << endl;
n = -1;
} else {
count += b;
n -= 2;
}
}
if(n == 0){
cout << count << endl;
n = 0;
} else if(n == 1) {
cout << count + a << endl;
n = 0;
}
}
}
}
return 0;
}