首页 技术 正文
技术 2022年11月18日
0 收藏 488 点赞 3,328 浏览 1639 个字

Problem Description

Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me what day it is ?

Input

There are multiply cases.

One line is one case.

There are three integers, year(0< year<10000), month(0<=month<13), day(0<=day<32).

Output

Output one line.

if the date is illegal, you should output “illegal”. Or, you should output what day it is.

Sample Input

2007 11 17

Sample Output

Saturday

这个题目的某个日期是星期几,和真正的日历是不一样的!!!

所以,用Java的日期类Calendar是过不了的。

只能自己写囖。。。题目意思是:1 1 1是星期一!

而事实上,1 1 1是星期六。不要问我为什么,我也不知道。。。

package cn.hncu.acm;import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;public class P2133 { public static void main(String[] args) throws ParseException {
String[] week = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int yuee[][]={{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}};
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int y = sc.nextInt();
int m = sc.nextInt();
int d = sc.nextInt();
if((yunn(y)==0&&m==2&&d==29)||m>12||d>yuee[yunn(y)][m]||m==0||d==0||y==0)
{
System.out.println("illegal");
continue;
}
/*
//题目是有问题的
//1 1 1 应该是星期六,具体为什么看网上资料。
//这个题目要求已知1 1 1是星期一
String[] week = {"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
String strTime = y+"-"+m+"-"+d;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(format.parse(strTime));
System.out.println(week[c.get(Calendar.DAY_OF_WEEK)]); */
int s=0;
for(int i=1;i<y;i++){
if(yunn(i)==1){
s+=366;
}else{
s+=365;
}
} for(int i=1;i<m;i++){
s+=yuee[yunn(y)][i];
}
s+=d;
s=s%7;
System.out.println(week[s]);
}
} public static int yunn(int xx)
{
if((xx%4==0&&xx%100!=0)||(xx%400==0))
return 1;//是闰年
return 0;//不是闰年
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291