Submission

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

Score: 10

User: Pera

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

Language: c

Time: 0.002 second

Submitted On: 2024-10-13 12:26:01

#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

    int sumday = 0;
    if (inputm < 8) {
        for (int i = inputm - 1; i < 7; i++) {
            sumday += months[i];
        }
        sumday += 12;
    } else if (inputm == 8) {
        sumday += 11;
    } else {
        for (int i = inputm - 1; i >= 7; i--) {
            sumday += months[i];
        }
        sumday += 12;
    } 

    int mothersday = (inputd + sumday) % 7;
    if (mothersday == 0) mothersday = 7;

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