49262023-04-07 13:01:40zolmikiVilágnaptár (45 pont)javaRuntime error 0/4593ms52044 KiB
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class main {

    static class Date {
        private int year;
        private int month;
        private int day;

        private int [] normalMonthLengths;
        private int [] worldMonthLenghts;
        private boolean isLeapYear;

        public Date(int year, int month, int day){
            this.year = year;
            this.month = month;
            this.day = day;
            this.isLeapYear = year % 4 == 0;
            this.normalMonthLengths = new int[]{31, this.isLeapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            this.worldMonthLenghts = new int[]{31, 30, 30, 31, 30, this.isLeapYear ? 31 : 30, 31, 30, 30, 31, 30, 31};
        }

        public void convertToWorldDate(){
            int passedDays = this.day;
            for(int i = this.month - 1; i >= 0; i--){
                passedDays += this.normalMonthLengths[i];
            }

            int worldMonth = 0;
            int worldDay = 0;

            for(int i = 0; i < 12; i++){
                if(passedDays - this.worldMonthLenghts[i] >= 0){
                    passedDays -= this.worldMonthLenghts[i];
                    worldMonth++;
                }
            }
            worldDay = passedDays;

            this.month = worldMonth;
            this.day = worldDay;
        }

        public String toString(){
            if(this.month == 12 && this.day == 31){
                return this.year + " 12 VN";
            } else if(this.isLeapYear && this.month == 7 && this.day == 0){
                return this.year + " 6 SZN";
            } else {
                return this.year + " " + this.month + " " + this.day;
            }
        }
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String [] readed  = br.readLine().split(" ");
        Date first = new Date(Integer.parseInt(readed[0]), Integer.parseInt(readed[1]), Integer.parseInt(readed[2]));
        first.convertToWorldDate();
        System.out.println(first);
    }
}
SubtaskSumTestVerdictTimeMemory
base0/45
1Runtime error0/093ms46356 KiB
2Runtime error0/090ms46892 KiB
3Runtime error0/086ms48216 KiB
4Runtime error0/285ms48288 KiB
5Runtime error0/290ms49072 KiB
6Runtime error0/386ms49900 KiB
7Runtime error0/383ms49780 KiB
8Runtime error0/382ms50496 KiB
9Runtime error0/383ms50928 KiB
10Runtime error0/383ms50952 KiB
11Runtime error0/382ms50308 KiB
12Runtime error0/383ms50628 KiB
13Runtime error0/390ms51216 KiB
14Runtime error0/386ms51412 KiB
15Runtime error0/390ms51004 KiB
16Runtime error0/386ms51940 KiB
17Runtime error0/383ms52044 KiB
18Runtime error0/283ms51672 KiB
19Runtime error0/382ms51556 KiB