当前位置:网站首页>CCF 201509-2 date calculation
CCF 201509-2 date calculation
2022-07-25 09:57:00 【Tobi_ Obito】
subject
Problem description
Given a year y And an integer d, Ask the first of the year d What's the day ?
Pay attention to the leap year 2 Monthly 29 God . One of the following conditions is leap year :
1) The year is 4 Integer multiple , And it's not 100 Integer multiple ;
2) The year is 400 Integer multiple .
Input format
The first line of input contains an integer y, Indicates the year , The year is 1900 To 2015 Between ( contain 1900 and 2015).
The second line of input contains an integer d,d stay 1 to 365 Between .
Output format
Output two lines , One integer per row , The month and date of the answer respectively .
The sample input
2015
80
Sample output
3
21
The sample input
2000
40
Sample output
2
9
Problem analysis
A basic date type topic , Go straight to the code .
Code
#include<cstdio>
using namespace std;
int AbnormalYear(int year){
if((year % 4 == 0 && year % 100!=0) || year % 400 == 0)
return 1;
return 0;
}
int main(){
int year,day,i,t;
int month[2][13];//[1][x]- Leap year [0][x]- Non leap year
month[0][1] = month[1][1] = 0;
month[0][2] = month[1][2] = 31;
month[0][3] = 59;
month[0][4] = 90;
month[0][5] = 120;
month[0][6] = 151;
month[0][7] = 181;
month[0][8] = 212;
month[0][9] = 243;
month[0][10] = 273;
month[0][11] = 304;
month[0][12] = 334;
for(int i=3;i<=12;i++)
month[1][i] = month[0][i] + 1;
scanf("%d %d",&year,&day);
t = AbnormalYear(year);
for(i=12;month[t][i] >= day;i--);
printf("%d\n%d\n",i,day-month[t][i]);
return 0;
}
边栏推荐
- CCF 201509-2 日期计算
- AMD EPYC 9664旗舰规格曝光:96核192线程 480MB缓存 3.8GHz频率
- Internal structure of SOC chip
- 【建议收藏】靠着这些学习方法,我入职了世界五百强——互联网时代的“奇技淫巧”
- 工程仪器振弦传感器无线采集仪的采集数据发送方式及在线监测系统
- 【RNN】剖析RNN 之 从RNN-(Simple|LSTM) 到 序列生成 再到 seq2seq框架(encoder-decoder,或称为seq2seq)
- 单目深度估计自监督模型Featdepth解读(上)——论文理解和核心源码分析
- MLX90640 红外热成像仪测温模块开发笔记(一)
- Introduction to testbench
- Verdi 基础介绍
猜你喜欢

Defect detection network -- hybrid supervision (kolektor defect data set reproduction)

【机器翻译】SCONES——用多标签任务做机器翻译

【建议收藏】靠着这些学习方法,我入职了世界五百强——互联网时代的“奇技淫巧”

CCF 201604-2 俄罗斯方块

Store to-do items locally (improve on to-do items)

Development history of convolutional neural network (part)

单目深度估计自监督模型Featdepth解读(下)——openMMLab框架使用

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

Arm preliminaries
![[dimension reduction strike] Hilbert curve](/img/bb/c2488f29721bdc413d709ee4bfaddf.png)
[dimension reduction strike] Hilbert curve
随机推荐
从Anaconda到TensorFlow到Jupyter一路踩坑一路填平
First knowledge of opencv4.x --- image histogram matching
Introduction to testbench
SystemVerilog syntax
OC -- packaging class and processing object
T5论文总结
ADC introduction
ADC introduction
~3 CCF 2022-03-2 travel plan
Internal structure of SOC chip
从鱼眼到环视到多任务王炸——盘点Valeo视觉深度估计经典文章(从FisheyeDistanceNet到OmniDet)(上)
OC -- Inheritance and polymorphic and pointer
MySQL与Navicat安装和踩坑
Visualization of sensor data based on raspberry pie 4B
CDA LEVELⅠ2021新版模拟题一(附答案)
Introduction to armv8 general timer
[deep learning] self encoder
【成长必备】我为什么推荐你写博客?愿你多年以后成为你想成为的样子。
Terminal definition and wiring of bsp3 power monitor (power monitor)
LoRA转4G及网关中继器工作原理