Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: vern6767
Problemset: ปฏิทินวันแม่
Language: cpp
Time: 0.004 second
Submitted On: 2026-09-21 13:48:32
#include <iostream>
#include <string>
using namespace std;
int main() {
int month[12][2] = {
{1, 31},
{2, 28},
{3, 31},
{4, 30},
{5, 31},
{6, 30},
{7, 31},
{8, 31},
{9, 30},
{10, 31},
{11, 30},
{12, 31}
};
int date[3] = {1, 1, 0};
int mothersday[2] = {8, 12};
cin >> date[0];
cin >> date[2];
while (date[0] != mothersday[0]) {
if (date[0] < mothersday[0]) {
if (date[1] == month[date[0]-1][1]) {
date[1] = 0;
date[0] += 1;
}
date[1] += 1;
date[2] = max((date[2]+1)%8, 1);
} else if (date[0] > mothersday[0]) {
date[1] -= 1;
date[2] = date[2]-1;
if (date[2] == 0) {
date[2] = 7;
}
if (date[1] == 0) {
date[1] = month[date[0]-2][1];
date[0] -= 1;
}
}
}
while (date[1] != mothersday[1]) {
if (date[1] < mothersday[1]) {
date[1] += 1;
date[2] = max((date[2]+1)%8, 1);
} else if (date[1] > mothersday[1]) {
date[1] -= 1;
date[2] = date[2]-1;
if (date[2] == 0) {
date[2] = 7;
}
}
}
cout << date[2];
return 0;
}