POJ 2080
import java.util.*;
public class Main { public static void main(String args[]){
Scanner cin=new Scanner(System.in);
int num;
while(true){
num=cin.nextInt();
if(num==-)
break;
num_year(num);
num_last(num);
}
}
public static boolean judge_leap(int num){
return (num%==&&num%!=)||(num%==);
}
public static void num_year(int num){
int one_year=;
int sum=;
int year=;
while(sum<=num){ one_year=;
if(judge_leap(year))
one_year++;
sum+=one_year;
year++;
}
num-=(sum-one_year);
System.out.print(year-);
num_month(num,year-); }
public static void num_month(int num,int year){
int[] month=new int[]{,,,,,,,,,,,,};
int sum=;
int i=;
while(sum<=num){
if(judge_leap(year)&&i==)
month[i]++;
sum+=month[i];
i++; }
num-=(sum-month[i-]);
System.out.print("-");
if(i-<)
System.out.print();
System.out.print(i-);
num_day(num);
}
public static void num_day(int num){
System.out.print("-");
if(num+<)
System.out.print();
System.out.print(num++" "); }
public static void num_last(int num){
num+=;
num=num%;
switch(num){
case :System.out.println("Monday");break;
case :System.out.println("Tuesday");break;
case :System.out.println("Wednesday");break;
case :System.out.println("Thursday");break;
case :System.out.println("Friday");break;
case :System.out.println("Saturday");break;
case :System.out.println("Sunday");break;
}
}
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 2080的更多相关文章
- POJ 2080 Calendar(很水的模拟)
刚开始一直WA,才发现原来代码中两处减去年份.月份的天数的判断条件用的是>=,虽然最后考虑n=0要退回一天的情况,但还是WA.后来改成>的条件判断,省去了考虑n=0的麻烦,AC. 此题无非 ...
- POJ 2080:Calendar
Calendar Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 12546 Accepted: 4547 Descrip ...
- A过的题目
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- Poj(3686),最小权匹配,多重匹配,KM
题目链接 The Windy's | Time Limit: 5000MS | Memory Limit: 65536K | | Total Submissions: 4939 | Accepted: ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
随机推荐
- static 与 final 修饰符
A) 用static(静态)修饰属性:一个类生成了N个对象,这些对象会共同使用一份静态的成员变量.一个对象对这个成员变量进行修改,其他对象的该成员变量的值也会随之变化. B) 我们可以通过 类名.成员 ...
- 【转载】MongoDB参数
我们可以通过mongod --help查看mongod的所有参数说明,以下是各参数的中文解释. 基本配置–quiet# 安静输出 –port arg# 指定服务端口号,默认端口27017 –bind_ ...
- Effiective C++ (一)
最近在看Effective C++ ,同时将总结一下里边的重要知识点: ########################## module 1 #################### ...
- poj 2777 Count Color
题目连接 http://poj.org/problem?id=2777 Count Color Description Chosen Problem Solving and Program desig ...
- Go中简单的文件读写
Go中的ioutil包可以方便的实现文件读写.代码: package main import ( "fmt" "io/ioutil" ) func main() ...
- iOS学习之C语言结构体
结构体:用来存放相同类型数据或者不同类型数据的自定义类型. 结构体定义(声明) struct 结构体名 { 成员变量1; 成员变量2; ... }; typedef 现有类型 新的类 ...
- IOS之表视图添加索引
我们要实现的效果如下. 1.修改ControlView.h,即添加变量dict,用于存储TabelView的数据源. #import <UIKit/UIKit.h> @interface ...
- TableViewCell Swipe to Delete and More Button(like mail app in iOS7 or later)
在iOS7系统的Mail App中TableViewCell的一个功能让我们做TableView的比较羡慕,就是滑动cell,右边出现了两个按钮,如下: 网上在github上有很多大牛用custom ...
- Linux rsync 同步
rsync 是一个快速增量文件传输工具,它可以用于在同一主机备份内部的备分,我们还可以把它作为不同主机网络备份工具之用.本文主要讲述的是如何自架rsync服务器,以实现文件传输.备份和镜像.相对tar ...
- sharepoint 2010 重建遇到的问题
需要重新安装Sharepoint 2010 ,遇到问题记录下来,sharepoint中安装了热补丁和英文语言包. 卸载: 1.运行配置向导将服务器从服务场中脱离: 2.在管理中心中卸载sharepoi ...