Official

A - What month is it? 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 with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).


If \(X\) and \(Y\) are both small, like \(X=1\) and \(Y=1\) as in Sample Input \(2\), the answer is \(X+Y\). However, if \(X+Y\) is \(12\) or greater, as in Sample Input \(1\), the answer is \(X+Y\) minus \(12\), i.e. \(X+Y-12\).

The problem can be solved by appropriately implementing this.

Sample code (Python3)

x, y = map(int, input().split())
if x + y <= 12:
    print(x + y)
else:
    print(x + y - 12)

Sample code (C++)

#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	if (x + y <= 12) {
		cout << x + y << endl;
	} else {
		cout << x + y - 12 << endl;
	}
	return 0;
}

Sample code (C)

#include <stdio.h>
int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	if (x + y <= 12) {
		printf("%d\n", x + y);
	} else {
		printf("%d\n", x + y - 12);
	}
	return 0;
}

Sample code (Java)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (x + y <= 12) {
            System.out.println(x + y);
        } else {
            System.out.println(x + y - 12);
        }
        sc.close();
    }
}

posted:
last update: