Problem:
You can see the question to the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Code:
You can see the question to the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Code:
#include <bits/stdc++.h>
using namespace std;
main(){
int n;
int s[101];
cin>>n;
for(int i=0;i<n;i++){
cin>>s[i]; //Numbers are stored into array
}
/*Algorithm explanation
//when n is divided by 2 remainder is not 0, result is always odd.
//Plus First element and last element.. both of them must always be odd for this Algorithm to work as mentioned in question. */
(n%2 && s[0]%2 && s[n-1]%2)?cout<<"Yes":cout<<"No"; //Another form of if else.
}
No comments:
Post a Comment