B2047 Piecewise Function

#include <iostream> using namespace std; int main(){ float N, y; cin >> N; if(N < 5){//0 <= x < 5 y = -N + 2.5; } else if(N < 10){//5 <= x < 10 y = 2 - 1.5 * (N - 3) * (N - 3); } else {//10 <= x < 20 y = N / 2 - 1.5; } //Output result with 3 decimal places printf("%.3lf", y); return 0;}
B2050 Triangle Judgment

#include <iostream> using namespace std; int main(){ int a,b,c; cin >> a >> b >> c;//Input the lengths of the triangle sides //The sum of any two sides must be greater than the third side if(a + b > c && a + c > b && b + c > a){ cout << 1; } else { cout << 0; } return 0;}
B2051 Relationship Between Point and Square

#include <iostream> using namespace std; int main(){ int x,y; cin >> x >> y; //When the point's x,y coordinates are within the range of these four points (-1 to 1) if(x >= -1 && x <=1 && y >= -1 && y <= 1){ cout << "yes"; } else { cout << "no"; } return 0;}