Submission

Status:
PPPPPPPPP-P-PPP-PPPP

Score: 85

User: Cmoss9

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

Language: c

Time: 0.001 second

Submitted On: 2024-10-08 19:42:41

#include <stdio.h>
int main () {
    int month,startingdate,skip;
    scanf("%d %d",&month,&startingdate);
    if (month<=8) {
        for (int i = month;i<8;i++) {
        if (i==1||i==3||i==5||i==7||i==8) {
            skip = 3;
        }
        else if (i==2) {
            skip = 0;
        }
        else {
            skip = 2;
        }
        startingdate = (startingdate+skip)%7;
        if (startingdate == 0) {
            startingdate = 7;
        } // to month
    }
    }
    else {
        for (int i = month;i>8;i--) {
            if (i==10||i==12) {
                skip = 3;
            }
            else {
                skip = 2;
            }
            startingdate = (startingdate-skip)%7;
            if (startingdate == 0) {
                startingdate = 7;
            } // to month
        }
    }
    // to mother's day
    int motherday = (startingdate+11)%7;
    if (motherday == 0) {
        motherday = 7;
    }
    printf("%d",motherday);
}