Submission

Status:
PPPPPPPP-----PP-PPPP

Score: 70

User: Nagorn

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

Language: cpp

Time: 0.002 second

Submitted On: 2024-10-14 13:18:17

#include <stdio.h>
#define int long long

signed main() {
    int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int m, d;
    
    // Read month and the day corresponding to the first of that month
    scanf("%lld%lld", &m, &d);
    
    // Calculate the total days to reach Mother’s Day (12 August)
    // 12 August is 11 days after the start of August
    // That means 18 days from 1 August (31 days of July + 11 days of August)
    
    // Adjust for the months before August
    if (m < 8) {
        for (int i = m; i < 8; i++) {
            d += month[i];
        }
        d += 11; // 11 days of August
    } else {
        for (int i = 9; i <= 12; i++) {
            d += month[i];
        }
        d += 18; // 31 days of July + 18 to reach 12 August
    }
    
    // Calculate the day of the week
    d %= 7; // Get the day of the week
    
    // Adjust if 0 means Sunday (if required)
    if (d == 0) {
        d = 7;
    }

    printf("%lld", d);
    return 0;
}