Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Score: 100
User: tankunkid
Problemset: ปฏิทินวันแม่
Language: cpp
Time: 0.001 second
Submitted On: 2024-09-29 00:18:29
#include <stdio.h>
int main() {
int m, d, sumd = 0;
scanf("%d %d", &m, &d);
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int momm = 8;
int momd = 12;
while (d > 7) {
d -= 7;
}
if (m > momm) {
for (int i = 0; i < m-momm-1; i++) {
sumd += month[m-i-2];
}
sumd += 20;
} else if (m < momm) {
for (int i = 0; i < momm - m; i++) {
sumd += month[momm-i-2];
}
sumd += 11;
} else {
sumd += 11;
}
int date = 0;
if (m < momm) date = (sumd % 7) + d;
if (m > momm) date = d - (sumd % 7);
if (m == momm) date = (sumd % 7) + d;
if (date > 7) {
date -= 7;
}
if (date < 0) {
date += 7;
}
if (date == 0) date = 7;
printf("%d", date);
}