问题 A: 第几天(简单模拟)
来源:互联网 发布:知豆汽车能开几年 编辑:程序博客网 时间:2024/04/30 00:59
Problem Link:http://139.129.36.234/problem.php?cid=1015&pid=0
问题 A: 第几天
时间限制: 1 Sec 内存限制: 128 MB提交: 40 解决: 19
[提交][状态][讨论版]
题目描述
给定一个日期, 输出这个日期是该年的第几天。
输入
数据格式为 YYYY/MM/DD组成, 具体参见输入示例。另外,所有输入数据是合法的。
输出
对于每组输入数据,输出一行,表示该日期是该年的第几天。
样例输入
1985/01/202006/03/12
样例输出
2071
AC code:
#include<iostream>#include<algorithm>#include<stdio.h>#include<map>#include<math.h>#include<string.h>#include<queue>#include<vector>#include<set>#define LL long long#define exp 1e-9#define MAXN 1000010 using namespace std;int mon[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,0,31,29,31,30,31,30,31,31,30,31,30,31};int isleap(int y){return ((y%4==0&&y%100!=0)||y%400==0);}int day(int y,int m,int d){int i,id,sum;id=isleap(y);sum=0;for(i=1;i<m;i++){sum+=mon[id][i];}sum+=d;return sum;}int main( ) { //freopen("D:\\in.txt","r",stdin);int y,m,d; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF){printf("%d\n",day(y,m,d));}return 0; }
0 0
- 问题 A: 第几天(简单模拟)
- NOJ1008 第几天(模拟)
- 第几天的问题
- 九度OJ 1070 今年的第几天?(模拟)
- oj-15-a-A-求第几天
- 第几天?(2005)
- hdu5477 A Sweet Journey(简单模拟)
- hdu 1228 A+B(简单模拟)
- Gym 100625A 间谍租车问题-简单模拟-(map的使用)
- 第几天(结构体)
- HDU2005 (第几天? 闰年)
- 当年第几天(极简版)
- HDU-2005(第几天)
- 问题一百一十五:第几天
- 关于求第几天的问题
- 今天是今年的第几天问题
- codeforces-3A-A. Winner (C++ && 简单模拟)
- 第几天
- Mac通过Docker部署Gitlab实践
- 小程序数据请求注意事项
- winform发布出错
- 段寄存器
- Struts2+Spring+Hibernate 框架在IntelliJ的集成
- 问题 A: 第几天(简单模拟)
- 对象模型 ------- Constructor 构造函数
- poj 1408 Fishnet
- 第一章 Dubbo风格的SPI-ExtensionLoader
- 3D游戏引擎系列一
- nyoj1057寻找最大数3
- Visual Studio Code 配置指南
- HDU3739 Anti LIS 最大流Dinic
- 蓝桥杯- 基础练习 闰年判断