算法日记(Java实现)第20160719(5)期——POJ1008
2016-07-20 03:19
337 查看
POJ1008
题目地址:http://poj.org/problem?id=1008
本题虽然思路很简单。却连续提交了七次,花费了大量时间检查错误才通过。主要是没有足够重视题目中的细节。
源代码如下:
题目地址:http://poj.org/problem?id=1008
本题虽然思路很简单。却连续提交了七次,花费了大量时间检查错误才通过。主要是没有足够重视题目中的细节。
源代码如下:
import java.util.Scanner; //POJ 1008 /*Date: 2016.07.19 * 1st: Compile Error J2SE不支持String使用switch语句 * 2nd: Runtime Error 月份算错 * 3rd: Wrong Answer 未打印n * 4th: Wrong Answer 日期算错 * 5th: Wrong Answer * 6th: Wrong Answer * 7th: Accepted */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); System.out.println(n); for (int i = 0; i < n; i++) { String day_ = sc.next(); int day = Integer.decode(day_.substring(0, day_.indexOf('.'))); String month_ = sc.next(); int year = sc.nextInt(); if (month_.equals("pop") ){ day += 0; } else if (month_.equals("no")) { day += 20; } else if (month_.equals("zip")) { day += 20 * 2; } else if (month_.equals("zotz")) { day += 20 * 3; } else if (month_.equals("tzec") ){ day += 20 * 4; } else if (month_.equals("xul") ){ day += 20 * 5; } else if (month_.equals("yoxkin")) { day += 20 * 6; } else if (month_.equals("mol") ){ day += 20 * 7; } else if (month_.equals("chen") ){ day += 20 * 8; } else if (month_.equals("yax") ){ day += 20 * 9; } else if (month_.equals("zac") ){ day += 20 * 10; } else if (month_.equals("ceh") ){ day += 20 * 11; } else if (month_.equals("mac") ){ day += 20 * 12; } else if (month_.equals("kankin")) { day += 20 * 13; } else if (month_.equals("muan") ){ day += 20 * 14; } else if (month_.equals("pax") ){ day += 20 * 15; } else if (month_.equals("koyab")) { day += 20 * 16; } else if (month_.equals("cumhu") ){ day += 20 * 17; } else { day += 20 * 18; } day += (year * 365 + 1); int tyear = day / 260; if(day != 0 && day % 260 == 0) tyear--; int number = day % 13; if(number == 0) number = 13; String[] ar = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; String name; if(day % 20 != 0) name = ar[day % 20 - 1]; else name = ar[19]; System.out.println(number + " " + name + " " + tyear); } } }
相关文章推荐
- Homework--数组冒泡排序
- Java包装类简介
- #500-3 异常
- java基础学习(5)疯狂java讲义第4章课后习题解答源码
- JAVA的基本数据类型
- javac不是内部或外部命令
- jre,jdk,jvm之间的关系
- javaee之servlet的基础练习
- java之01
- SpringAOP中的PointcutAdvisor
- 知识点:Java变量和数组的默认值
- javaee之servlet的方法详解
- 【职坐标】java面向对象前言——static关键字
- JavaWeb核心编程之(三.4)Servlet Context 配置
- Java学习中位运算符底层运算过程
- RxJava入门第八、九问(二)
- windows7下java配置环境
- java实现单例singleton的几种模式
- java环境配置--转载
- springMVC和jackson的版本