Algorithm
Problem Name: beecrowd | 2780
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2780
Robot Basketball
By OBI Brasil
Timelimit: 1
The OIBR organization, the International Robot Basketball Olympiad, is starting to have problems with two teams: the Bit Warriors and the Byte Bulls. It's just that the robots on these teams hit almost every pitch from any position on the court! Come to think of it, the basketball game would be awkward if players could hit any pitch, right? One of the measures that the OIBR is implementing is a new score for the launches, according to the distance from the robot to the beginning of the court. The court is 2000 centimeters long, as in figure.
Given the distance D of the robot to the beginning of the court, where the basket is, the rule is as follows:
• If D ≤ 800, the basket is worth 1 point;
• If 800 < D ≤ 1400, the basket is worth 2 points;
• If 1400 < D ≤ 2000, the basket is worth 3 points. The OIBR organization needs help to automate the game's scoreboard. Given the value of distance D, you must write a program to calculate the number of launch points.
Input
The first and only line of the input contains an integer D (0 ≤ D ≤ 2000) indicating the distance of the robots to the start of the block, in centimeters, at launch.
Output
Your program should produce a single line, containing an integer, 1, 2, or 3, indicating the launch season.
Input Samples | Output Samples |
1720 |
3 |
250 |
1 |
1400 |
2 |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iterator>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>
#include <utility>
#include <sstream>
#include<bitset>
using namespace std;
typedef long long ll;
typedef std::vector < double> vi;
#define PI acos(-1)
#define E 2.718281828459
#define g 9.81
int main(int argc, char** argv) {
int D;
cin >> D;
if(D >1400)
cout << 3 << endl;
else if(D > 800)cout << 2 << endl;
else cout << 1 << endl;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var D = Number(lines[0]);
if(D <= 800){
console.log('1');
}else if((800 < D) && (D <= 1400))
console.log('2');
else if((1400 < D) && (D <= 2000)){
console.log('3'>;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Java Programming
Code -
Java Programming
import java.util.Scanner;
import java.util.Locale;
public class Main {
public static void main(String[] args) {
Locale.setDefault(new Locale("en", "US"));
Scanner sc = new Scanner(System.in);
int D = sc.nextInt();
if (D < = 800)
System.out.println("1");
else if(800 < D && D < = 1400)
System.out.println("2");
else if(1400 < D && D <= 2000)
System.out.println("3");
sc.close(>;
}
}
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Python Programming
Code -
Python Programming
d = int(input())
if d <= 800:
print(1)
elif d <= 1400:
print(2)
else:
print(3)
Copy The Code &
Try With Live Editor
Input
Output