当前位置:网站首页>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;
}
边栏推荐
- VScode配置ROS开发环境:修改代码不生效问题原因及解决方法
- ADC introduction
- Solve the problem that esp8266 cannot connect mobile phones and computer hotspots
- Visualization of sensor data based on raspberry pie 4B
- Segmentation based deep learning approach for surface defect detection
- pytorch使用tensorboard实现可视化总结
- 【RNN】剖析RNN 之 从RNN-(Simple|LSTM) 到 序列生成 再到 seq2seq框架(encoder-decoder,或称为seq2seq)
- File -- first acquaintance
- First knowledge of opencv4.x ---- mean filtering
- Eco introduction
猜你喜欢

CDA Level1知识点总结之多维数据透视分析

深度估计自监督模型monodepth2在自己数据集的实战——单卡/多卡训练、推理、Onnx转换和量化指标评估

Gartner 2022年顶尖科技趋势之超级自动化

Temperature, humidity and light intensity acquisition based on smart cloud platform

Mixed supervision for surface defect detection: from weakly to fully supervised learning

从Anaconda到TensorFlow到Jupyter一路踩坑一路填平

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

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

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

TM1637带秒点四位LED显示器模块ARDUINO驱动程序
随机推荐
MySQL与Navicat安装和踩坑
LOAM 融合 IMU 细节之 TransformToEnd 函数
¥ 1-1 SWUST OJ 941: implementation of consolidation operation of ordered sequence table
CCF 201509-4 高速公路
MLX90640 红外热成像仪测温模块开发说明
ARMV8体系结构简介
CCF 201503-4 网络延时
js利用requestAnimationFrame实时检测当前动画的FPS帧率
First knowledge of opencv4.x --- image template matching
TensorFlow raw_rnn - 实现seq2seq模式中将上一时刻的输出作为下一时刻的输入
数据分析业务核心
VCS常用命令
用ESP32+TM1638实验NTP网络校时闹钟的ARDUINO代码
ECO简介
Segmentation based deep learning approach for surface defect detection
Gartner 2022年顶尖科技趋势之超级自动化
MLX90640 红外热成像仪测温模块开发笔记(一)
SystemVerilog syntax
预测2021年:加速实现RPA以外的超自动化成果
ARM预备知识