You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
641 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int qpow7(int a, int b)
{
int ret = 1;
for (; b; b >>= 1, a = a * a % 7)
if (b & 1)
ret = ret * a % 7;
return ret;
}
int s[300];
char rs[][13] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
int main()
{
for (int i = 1; i <= 294; i++)
s[i] = (s[i - 1] + qpow7(i, i)) % 7;
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
puts(rs[s[n % 294]]);
}
return 0;
}