Submission

Status:
P-P-P-PPPP-P-P---PPP

Score: 60

User: Cmoss9

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

Language: c

Time: 0.001 second

Submitted On: 2024-10-08 12:26:43

#include <stdio.h>
int main () {
    int month,startingdate;
    int 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 = 1;
            }
        }
        startingdate = (startingdate+11)%7;
    }
    else if (month>8) {
        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 = 1;
            }
        }
        startingdate = -1*((startingdate-19)%7);
    }
    else {
        startingdate = (startingdate+11)%7;
    }
    printf("%d",startingdate);
}