A - T-shirt Editorial by en_translator

If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar to problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (
「競プロ典型 90 問」(Typical 90 Problems of Competitive Programming) ( is a collection of typical 90 competitive programming problems; unfortunately, currently the problem statements are all Japanese.
「C++入門 AtCoder Programming Guide for beginners (APG4b)」( is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.

You can find the answer in the following flow.

  • If \(X \le A\), then the answer is \(1\);
  • otherwise, if \(X \le B\), then the answer is \(\frac{C}{B-A}\);
  • otherwise, the answer is \(0\).

This can be implemented with if statements.

Be careful of how to output real numbers. Especially, your answer may be judged to be a wrong answer due to the lack of digits to be output.
The way to handle this issue varies language to language. For example, one of the solutions in C++ is to use printf. In the sample code, the output format specifies that \(12\) digits after the decimal point should be printed.

Sample code (C++):

using namespace std;
int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  else if(x<=b){
    double res=c;
  return 0;

last update: