首页 技术 正文
技术 2022年11月16日
0 收藏 939 点赞 2,717 浏览 1684 个字

The Lucky Week


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Edward, the headmaster of the Marjar University, is very busy every day and always forgets the date.

There was one day Edward suddenly found that if Monday was the 1st, 11th or 21st day of that month, he could remember the date clearly in that week. Therefore, he called such week “The Lucky Week”.

But now Edward only remembers the date of his first Lucky Week because of the age-related memory loss, and he wants to know the date of the N-th Lucky Week. Can you help him?

Input

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

The only line contains four integers Y, M, D and N (1 ≤ N ≤ 109) indicating the date (Y: year, M: month, D: day) of the Monday of the first Lucky Week and the Edward’s query N.

The Monday of the first Lucky Week is between 1st Jan, 1753 and 31st Dec, 9999 (inclusive).

Output

For each case, print the date of the Monday of the N-th Lucky Week.

Sample Input

2
2016 4 11 2
2016 1 11 10

Sample Output

2016 7 11
2017 9 11

题意:当日期为 1,11,21 并且当天为周一时 认为这一周为Lucky Week
给出起始lucky week 问之后第N个lucky week的 日期题解:1.暴力找循环节 每400年中有2058个lucky week
2.然后就是暴力
  #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#define LL __int64
#define pi acos(-1.0)
#define mod 1
#define maxn 10000
using namespace std;
int month1[]={,,,,,,,,,,,,};
int month2[]={,,,,,,,,,,,,};
bool year(int ye)
{
if((ye%==&&ye%!=)||ye%==)
return true;
return false;
}
int t;
int y,m,d,n;
int main()
{
while(scanf("%d",&t)!=EOF)
{
for(int i=;i<=t;i++)
{
scanf("%d %d %d %d",&y,&m,&d,&n);
int exm1=n/;
exm1=exm1*;
int exm2=n%;
while(exm2)
{
if(d==||d==||d==)
exm2--;
if(exm2==)
break;
if(year(y))
{
d=d+;
if(month2[m]<d)
{
d=d-month2[m];
m=m+;
}
if(m>)
{
y=y+;
m=;
}
}
else
{
d=d+;
if(month1[m]<d)
{
d=d-month1[m];
m=m+;
}
if(m>)
{
y=y+;
m=;
}
}
}
cout<<y+exm1<<" "<<m<<" "<<d<<endl;
}
}
return ;
}

Lucky Week

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,083
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,558
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,407
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,180
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,817
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,900