Submission
Status:
PPPPPPPPP----PP-PPPP
Score: 75
User: kami
Problemset: ปฏิทินวันแม่
Language: cpp
Time: 0.001 second
Submitted On: 2024-10-17 00:44:19
#include <stdio.h>
int main() {
int m, d;
scanf("%d", &m);
scanf("%d", &d);
int months[12] = {31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31};
int total_days = 0;
if (m < 8) {
total_days = months[m - 1] - 1;
for (int i = m; i < 7; i++) {
total_days += months[i];
}
total_days += 12;
}
else if (m == 8) {
total_days = 12 - 1;
}
else {
total_days = 12;
for (int i = 7; i < m - 1; i++) {
total_days += months[i];
}
total_days += months[m - 1] - 1;
}
int day_of_week = ((d - 1 + total_days) % 7) + 1;
printf("%d\n", day_of_week);
return 0;
}