My issue
int n;
cin>>n;
//int income=0;
int N,X,Y;
for(int i=0;i<n;i++){
cin>>N>>X>>Y;
int income=0;
if(N%2==0){
income=N*X;
}
else{
int hour2=N/2;
int hour1=N-2*hour2;
income=(hour2*Y) + (hour1*X);
}
cout<<income<<endl;
}
return 0;
its not taking all test cases
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n;
cin>>n;
//int income=0;
int N,X,Y;
for(int i=0;i<n;i++){
cin>>N>>X>>Y;
int income=0;
if(N%2==0){
income=N*X;
}
else{
int hour2=N/2;
int hour1=N-2*hour2;
income=(hour2*Y) + (hour1*X);
}
cout<<income<<endl;
}
return 0;
}
Problem Link: Yoga Class Practice Coding Problem