Submission

Status:
P-PP-------P---P-P--

Score: 30

User: Pera

Problemset: ปฏิทินวันแม่

Language: c

Time: 0.002 second

Submitted On: 2024-10-13 12:05:20

#include <stdio.h>

int main(void) {
    int inputd, inputm;
    scanf("%d %d", &inputm, &inputd);

    int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // Jan to Dec

    // Calculate the total number of days from the beginning of the year
    int sumday = 0;
    for (int i = 0; i < inputm - 1; i++) {
        sumday += months[i];  // Sum all the days in the months before inputm
    }
    sumday += inputd;  // Add the days of the current month up to inputd

    // Calculate the day of the week for Mother's Day
    int mothersday = (sumday - 1 + 1) % 7; // +1 to adjust the range to 1-7
    if (mothersday == 0) mothersday = 7;  // Adjust for 0 being Sunday

    printf("%d\n", mothersday);
    return 0;
}