现在的位置: 首页 > 综合 > 正文

The 11th Zhejiang Provincial Collegiate Programming Contest— What day is that da

2017年10月03日 ⁄ 综合 ⁄ 共 1471字 ⁄ 字号 评论关闭

                                               
  What day is that day?


Time Limit: 2 Seconds      Memory Limit: 65536 KB


It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days?

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

There is only one line containing one integer N (1 <= N <= 1000000000).

Output

For each test case, output one string indicating the day of week.

Sample Input

2
1
2

Sample Output

Sunday
Thursday

Hint

A week consists of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.

思路: 先暴力打出1-1000之间所有天的星期数,然后用txt的搜索功能,查找前五个数字,就会找到循环节。长度为294

代码:

#include<stdio.h>
int main()
{
	int ans[295] = { -1, 1, 5, 4, 1, 4, 5, 5, 6, 0, 4, 6, 0, 6, 6, 0, 2, 0, 1, 6, 0, 0, 1, 5, 6, 3, 0, 6, 6, 0, 1, 4, 6, 5, 6, 6, 0, 2, 4, 5, 0,
		6, 6, 0, 4, 3, 0, 3, 4, 4, 5, 6, 3, 5, 6, 5, 5, 6, 1, 6, 0, 5, 6, 6, 0, 4, 5, 2, 6, 5, 5, 6, 0, 3, 5, 4, 5, 5, 6, 1, 3,
		4, 6, 5, 5, 6, 3, 2, 6, 2, 3, 3, 4, 5, 2, 4, 5, 4, 4, 5, 0, 5, 6, 4, 5, 5, 6, 3, 4, 1, 5, 4, 4, 5, 6, 2, 4, 3, 4, 4, 5,
		0, 2, 3, 5, 4, 4, 5, 2, 1, 5, 1, 2, 2, 3, 4, 1, 3, 4, 3, 3, 4, 6, 4, 5, 3, 4, 4, 5, 2, 3, 0, 4, 3, 3, 4, 5, 1, 3, 2, 3,
		3, 4, 6, 1, 2, 4, 3, 3, 4, 1, 0, 4, 0, 1, 1, 2, 3, 0, 2, 3, 2, 2, 3, 5, 3, 4, 2, 3, 3, 4, 1, 2, 6, 3, 2, 2, 3, 4, 0, 2,
		1, 2, 2, 3, 5, 0, 1, 3, 2, 2, 3, 0, 6, 3, 6, 0, 0, 1, 2, 6, 1, 2, 1, 1, 2, 4, 2, 3, 1, 2, 2, 3, 0, 1, 5, 2, 1, 1, 2, 3,
		6, 1, 0, 1, 1, 2, 4, 6, 0, 2, 1, 1, 2, 6, 5, 2, 5, 6, 6, 0, 1, 5, 0, 1, 0, 0, 1, 3, 1, 2, 0, 1, 1, 2, 6, 0, 4, 1, 0, 0,
		1, 2, 5, 0, 6, 0, 0, 1, 3, 5, 6, 1, 0, 0 };
	int t;
	scanf("%d", &t);
	while (t--)
	{
		int n;
		scanf("%d", &n);
		int sum = ans[n % 294];
		if (sum == 1)
			puts("Sunday");
		else if (sum == 2)
			puts("Monday");
		else if (sum == 3)
			puts("Tuesday");
		else if (sum == 4)
			puts("Wednesday");
		else if (sum == 5)
			puts("Thursday");
		else if (sum == 6)
			puts("Friday");
		else
			puts("Saturday");
	}
	return 0;
}





抱歉!评论已关闭.