Submission

Status:
PPPPPPPP---P-PPPPPPP

Score: 80

User: Pera

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

Language: c

Time: 0.001 second

Submitted On: 2024-10-13 12:17:42

#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 - 1;
    } 

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

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