当前位置:网站首页>CCF 201503-3 Festival
CCF 201503-3 Festival
2022-07-25 09:57:00 【Tobi_ Obito】
subject
Problem description
There is a kind of festival whose date is not fixed , But rather “a Month's Day b A few weeks c” In the form of , For example, mother's Day is set on the second Sunday of May every year .
Now? , Here you are. a,b,c and y1, y2(1850 ≤ y1, y2 ≤ 2050), I hope you output from... Ad y1 Year to ad y2 Every year during the year a Month's Day b A few weeks c Date .
Tips : Rules about leap years : The year is 400 Is a leap year , Otherwise the year is 4 Is not a multiple of 100 The multiple of is leap year , Other years are not leap years . for example 1900 A year is not a leap year , and 2000 Year is a leap year .
For your convenience , It is known that 1850 year 1 month 1 It's Tuesday .
Input format
The input contains exactly one line , There are five integers a, b, c, y1, y2. among c=1, 2, ……, 6, 7 Monday means Monday 、 Two 、……、 6、 ... and 、 Japan .
Output format
about y1 and y2 Every year between , Include y1 and y2, Output a line in the order of the year from small to large .
If this year's a Yue di b A few weeks c Do exist , with "yyyy/mm/dd" Format output , That is, the four digit year , Two digit months , Double digit date , Use a slash in the middle “/” Separate , If the number of digits is insufficient, fill in zero .
If this year's a Yue di b A few weeks c There is no such thing as , The output "none"( No double quotes ).
The sample input
5 2 7 2014 2015
Sample output
2014/05/11
2015/05/10
Evaluate use case size and conventions
All evaluation cases meet :1 ≤ a ≤ 12,1 ≤ b ≤ 5,1 ≤ c ≤ 7,1850 ≤ y1, y2 ≤ 2050.
Problem analysis
This is about the date , First, consider each year in the given interval : The idea is to get from 1850 year 1 month 1 How many days does it take to reach the target date TOTAL_DAYS, Then on 7 The remainder can be mapped to the day of the week ( This mapping is based on 1850 year 1 month 1 The day is set on Tuesday ). In order to judge whether the date is legal , To put TOTAL_DAYS The specific date is , Here are some details . The following code is given directly .
Code
#include<cstdio>
using namespace std;
int AbnormalYear(int year){
if((year%4==0&&year%100!=0)||year%400==0)
return 1;
return 0;
}
bool Legal(int abnormal,int mon,int day){
switch(mon){
case 4:
if(day<=30)
return true;
break;
case 6:
if(day<=30)
return true;
break;
case 9:
if(day<=30)
return true;
break;
case 11:
if(day<=30)
return true;
break;
case 2:
if(day<=28+abnormal)
return true;
break;
default:
if(day<=31)
return true;
}
return false;
}
int main(){
int month_total[13];
month_total[1] = 0;
month_total[2] = 31;
month_total[3] = 59;
month_total[4] = 90;
month_total[5] = 120;
month_total[6] = 151;
month_total[7] = 181;
month_total[8] = 212;
month_total[9] = 243;
month_total[10] = 273;
month_total[11] = 304;
month_total[12] = 334;
int abnormal_month_total[13];
abnormal_month_total[1] = 0;
abnormal_month_total[2] = 31;
abnormal_month_total[3] = 60;
abnormal_month_total[4] = 91;
abnormal_month_total[5] = 121;
abnormal_month_total[6] = 152;
abnormal_month_total[7] = 182;
abnormal_month_total[8] = 213;
abnormal_month_total[9] = 244;
abnormal_month_total[10] = 274;
abnormal_month_total[11] = 305;
abnormal_month_total[12] = 335;
int mon,n,weekday,from,to,sum = 0,t1,t2,t3;
const int week[7] = {2,3,4,5,6,7,1};
scanf("%d %d %d %d %d",&mon,&n,&weekday,&from,&to);
sum += (from - 1850) * 365;
for(int i=1850;i<from;i++)
sum += AbnormalYear(i);
for(int i=from;i<=to;i++){
if(!AbnormalYear(i)){
t1 = sum + month_total[mon];// First day of the month
t2 = week[t1%7];// That month 1 What day is the th
t3 = 1 + (n - 1) * 7;
if(weekday<t2){
t3 += 7 - t2 + weekday;// The day of the month
}
else if(weekday>t2){
t3 += weekday - t2;
}
//else t3 = t3;
if(Legal(0,mon,t3))
printf("%d/%02d/%02d\n",i,mon,t3);
else
printf("none\n");
sum += 365;
}
else{
t1 = sum + abnormal_month_total[mon];// First day of the month
t2 = week[t1%7];// That month 1 What day is the th
t3 = 1 + (n - 1) * 7;
if(weekday<t2){
t3 += 7 - t2 + weekday;// The day of the month
}
else if(weekday>t2){
t3 += weekday - t2;
}
//else t3 = t3;
if(Legal(1,mon,t3))
printf("%d/%02d/%02d\n",i,mon,t3);
else
printf("none\n");
sum += 366;
}
}
return 0;
}
边栏推荐
- 手持振弦采集仪对振弦传感器激励方法和激励电压
- Introduction to low power consumption and UPF
- 预测2021年:加速实现RPA以外的超自动化成果
- dp-851
- Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (III)
- ECO简介
- testbench简介
- SD/SDIO/EMMC
- Introducing MLOps 解读(一)
- Exciting method and voltage of vibrating wire sensor by hand-held vibrating wire acquisition instrument
猜你喜欢

【近万字干货】别让你的简历配不上你的才华——手把手教你制作最适合你的简历

ARMV8体系结构简介

MLX90640 红外热成像仪测温模块开发笔记(五)

Data viewing and parameter modification of multi-channel vibrating wire, temperature and analog sensing signal acquisition instrument

Introduction to armv8 general timer

Camera attitude estimation
![[dimension reduction strike] Hilbert curve](/img/bb/c2488f29721bdc413d709ee4bfaddf.png)
[dimension reduction strike] Hilbert curve

从鱼眼到环视到多任务王炸——盘点Valeo视觉深度估计经典文章(从FisheyeDistanceNet到OmniDet)(下)

VS无线振弦采集仪蓝牙功能的使用

基于PackNet的演进——丰田研究院(TRI)深度估计文章盘点(下)
随机推荐
一个硬件攻城狮的经济学基础
First knowledge of opencv4.x --- image histogram matching
[dimension reduction strike] Hilbert curve
【RNN】剖析RNN 之 从RNN-(Simple|LSTM) 到 序列生成 再到 seq2seq框架(encoder-decoder,或称为seq2seq)
关于MLOps中的数据工程,你一定要知道的.......
testbench简介
ADC introduction
First knowledge of opencv4.x ---- mean filtering
Segmentation based deep learning approach for surface defect detection
Mlx90640 infrared thermal imager temperature measurement module development notes (V)
First knowledge of opencv4.x --- drawing shapes on images
Binary Cross Entropy真的适合多标签分类吗?
Creation of adjacency matrix of undirected connected graph output breadth depth traversal
CDA Level1复盘总结
CCF 201503-4 网络延时
Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (II)
FLASH read / write operation and flash upload file of esp8266
Server CUDA toolkit multi version switching
OC -- Inheritance and polymorphic and pointer
Terminal definition and wiring of bsp3 power monitor (power monitor)