Submission

Status:
PPPPPPPPP----PP-PPPP

Score: 75

User: Pera

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

Language: c

Time: 0.002 second

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

#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 += 12;
    } else {
        for (int i = inputm - 1; i > 7; i--) {
            sumday += months[i];
        }
        sumday = 365 - sumday + 12;
    } 

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

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