Tính giá trị Y Phần 2
Tìm giá trị của y như sau:
y = x^3 + 2*x^2 + 5x, với x >
y = 3x^2 − 2x + 4, với 1 ≤ x ≤ 3
y = 5x − 8, với x < 1
Input Dòng duy nhất là số nguyên x thỏa |x| ≤ 105 .
Output In ra kết quả cần tìm.
Examples
standard input 2
standard output 4
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long x;
cin>>x;
if(x > 3)
cout<<pow(x,3) + 2*pow(x,2) + 5*x;
if(x >= 1 && x <= 3)
cout<<pow(x,2) - 2*x + 4;
if(x < 1)
cout<<5*x - 8;
return 0;
}