Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: polikanta

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

Language: cpp

Time: 0.003 second

Submitted On: 2026-08-15 19:39:59

#include <stdio.h>

int main() {
    int m, d;
    int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    scanf("%d", &m);
    scanf("%d", &d);

    int total = 0;
    int answer;

    if (m <= 8){
        for (int i = m; i < 8; i++){
            total += days[i];
        }
        total += 11;
        answer = (d + total) % 7;
    }
    else{
        for (int i = 8; i < m; i++){
            total += days[i];
        }
        total = total - 11;
        answer = (d - (total % 7) + 7) % 7;
    }
    if (answer == 0) answer = 7;
    printf("%d", answer);

    return 0;
}