当前位置:网站首页>OpenJudge NOI 1.13 18:Tomorrow never knows?
OpenJudge NOI 1.13 18:Tomorrow never knows?
2022-06-11 02:49:00 【Junyi_ noip】
【 Topic link 】
OpenJudge NOI 1.13 18:Tomorrow never knows?
【 Topic test site 】
1. simulation
【 Their thinking 】
Simulate the change of date value
To calculate the next day of the current date , First the “ Japan ” increase 1,
If “ Japan ” The value of exceeds the number of days in the current month , Then the month increases 1,“ Japan ” Turn into 1.
If the value of the month increases 1 After that, it exceeded 12, Then the year increases 1, The month becomes 1.
Here we need to set up two functions
isLeap Function to determine whether a year is a leap year , aliquot 400 Or not divisible 100 But it can be divided 4 The year of is leap year .
getMonthDay Find the number of days in a certain month of a certain year , Here we will consider the impact of leap years .
【 Solution code 】
solution 1:
#include<bits/stdc++.h>
using namespace std;
bool isLeap(int y)
{
return y%400 == 0 || y%100 != 0 && y%4 == 0;
}
int getMonthDay(int y, int m)
{
if(m == 2)
{
if(isLeap(y))
return 29;
else
return 28;
}
else if(m == 4 || m == 6 || m == 9 || m == 11)
return 30;
else
return 31;
}
int main()
{
int y, m, d;
scanf("%d-%d-%d", &y, &m, &d);
d++;
if(d > getMonthDay(y, m))
{
d = 1;
m++;
if(m > 12)
{
y++;
m = 1;
}
}
printf("%d-%02d-%02d", y, m, d);
return 0;
}
边栏推荐
- 近期学习和更新计划
- AOSP ~ Logcat Chatty 行过期
- Metal organic framework MOF Al (Diba), MOF Zr (Diba), MOF Fe (Diba) loaded with curcumin / carboxybenzylpenicillin /mtx methotrexate / paclitaxel ptx/ DOX / cisplatin cddp/cpt camptothecin and other d
- jdbc工具类的问题
- If you understand the logic of mining and carbon neutrality, you will understand the 100 billion market of driverless mining areas
- Prophet
- AOSP ~ modify WebView default implementation
- One line of code solves the problem that the time to fetch datetime from MySQL database is less than eight hours
- Prophet
- PHP starts OpenSSL and reports OpenSSL support=> disabled (install ext/openssl)
猜你喜欢

AOSP ~ modify WebView default implementation

When the interviewer opens his mouth, he comes to compose. Is this the case now?

A collection of common ADB commands for app testing

弄懂了采矿业与碳中和的逻辑,就读懂了矿区无人驾驶的千亿市场

ShaderGraphs

企业展厅设计能为企业带来什么?

基于互联网架构演进, 构建秒杀系统

逃离大城市的年轻人:扛住了房价和压力,没扛住流行病

How to guarantee the data quality of data warehouse?

Looking at the ups and downs of the mobile phone accessories market from the green Union's sprint for IPO
随机推荐
微信模版消息errcode“:40165,“errmsg“:“invalid weapp pagepath
从绿联冲刺IPO,看手机配件市场沉浮录
Link list of high frequency written interview question brushing summary (distribution explanation & code annotation)
App test_ Summary of test points
Whether the software test needs to master the programming ability
Unity animator rewind
Kotlin apply method
ADVANCE.AI首席执行官寿栋将在2022新兴市场品牌出海线上峰会分享跨境电商运用AI技术合规
近期学习和更新计划
Common vocabulary of software testing English
How to handle error code 30204-44 when installing office 2016 in win10?
Forest v1.5.22 发布!支持Kotlin
【189. 轮转数组】
AOSP ~ modify default volume
AOSP ~ WIFI默认开启 + GPS默认关闭 + 蓝牙默认关闭 + 旋转屏幕关闭
When a logical deletion encounters a unique index, what are the problems and solutions?
[interview question 17.04. missing numbers]
Uni app - one click access to user information
How to read PMBOK guide in 3 steps (experience + data sharing)
ADVANCE. AI CEO Shoudong will share the compliance of cross-border e-commerce using AI technology at the 2022 emerging market brands online Summit