AtCoder Beginner Contest 177 A Problem "Don't be late" Explanation (Python3, C ++, Java)

Hi everyone (who after the contest Good evening!) Is Rute!

AtCoder Beginner Contest 177 </ b> is about to begin!

Explanation of each problem

A problem B problem C problem
This article in preparation in preparation

In this article, I will mainly explain the A problem "Don't be late" </ b>! !!

Problem summary

Takahashi is meeting with Aoki. The meeting place is $ D $ meters away from Takahashi's house, and the meeting time is $ T $ minutes later. When Takahashi leaves home and moves straight to the meeting place at $ S $ meters per minute, determine if he is in time for the meeting place.

Constraint

・ $ 1 \ leq D \ leq 10000 $ ・ $ 1 \ leq T \ leq 10000 $ ・ $ 1 \ leq S \ leq 10000 $

Commentary

All you have to do is determine if you are in time for the meeting place. In other words, it is only necessary to determine whether the distance traveled by $ T $ at a speed of $ S $ meters per minute is greater than or equal to $ D $ meters. Expressed as an expression, it is sufficient to conditionally branch whether it is $ D \ leq S × T $.

Below are examples of answers in each language (Python3, Java, C ++).

Example of answer for each language

Python3 solution example

{ABC177A.py}


d,t,s = map(int,input().split())
if d <= s * t:
    print("Yes")
else:
    print("No")
C ++ solution example

{ABC177A.cpp}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if ( d <= s * t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
Java solution example

{ABC177A.java}


import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int d = scan.nextInt();
    int t = scan.nextInt();
    int s = scan.nextInt();
    if (d <= s * t){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Many problems related to conditional branching are also asked at ABC, ABC175 Air Conditioner, ABC164 Sheep and Wolves, etc. Is true.

This concludes the explanation of the A problem </ b>. Next is the explanation of B problem </ b>! !!

Recommended Posts