Submission

Status:
---PPPPPP----PP-PPPP

Score: 60

User: Cmoss9

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

Language: c

Time: 0.002 second

Submitted On: 2024-10-09 23:26:39

#include<stdio.h>
int main () {
    int month,startingdate,result;
    scanf("%d %d",&month,&startingdate);
    if (month<=8) {
        for (int i = month;i<8;i++) {
            if (i==1||i==3||i==5||i==7) {
                startingdate = (startingdate+3)%7;
            }
            else if (i==2) {
                startingdate = startingdate;
            }
            else {
                startingdate = (startingdate+2)%7;
            }
        }
    if (month == 1 || month == 2) {
            result = ((startingdate+12)%7);
            if (result == 0) {
                result = 7;
            }
        }
    else {
        result = ((startingdate+11)%7);
            if (result == 0) {
                result = 7;
            }
        }
    printf("%d",result);
    } else {
        for (int i = month;i>8;i--) {
            printf("%d %d\n",i,startingdate);
            if (i==10||i==12) {
                startingdate = (startingdate-3);
                if (startingdate < 0) {
                    startingdate = 7 + startingdate;
                }
                startingdate = (startingdate)%7;
            }
            else {
                startingdate = (startingdate-2);
                if (startingdate < 0) {
                    startingdate = 7 + startingdate;
                }
                startingdate = (startingdate)%7;
            }
            printf("%d %d\n",i,startingdate);
        }
        if (month == 9 || month == 11) {
            result = ((startingdate+10)%7);
            if (result == 0) {
                result = 7;
            }
        }
        else {
            result = ((startingdate+10)%7);
            if (result == 0) {
                result = 7;
            }
        }
    printf("%d",result);
    }
}