1 条题解
-
0
JAVA ac代码: 这题就是日期模板题目了 只需要先初始下bihua数组就好做了
import java.util.*; import java.util.StringTokenizer; import java.io.*; public class Main { static int months[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; static int bihua[]={13,1,2,3,5,4,4,2,2,2}; public static void main(String[] args) { int year=in.nextInt(),month=in.nextInt(),day=in.nextInt(); int count=0; for(int y=2000;y<=year;y++){ if(leap(y)){ months[2]=29; }else{ months[2]=28; } for(int m=1;m<=12;m++){ for(int d=1;d<=months[m];d++){ int ans=0; int y1=y/1000; int y2=y/100%10; int y3=y/10%10; int y4=y%10; int m1=m/10; int m2=m%10; int d1=d/10; int d2=d%10; ans=bihua[y1]+bihua[y2]+bihua[y3]+bihua[y4]+bihua[m1]+bihua[m2]+bihua[d1]+bihua[d2]; if(ans>50) count++; if(y==year&&m==month&&d==day){ out.println(count); out.close(); return; } } } } } public static boolean leap(int year){ return (year%400==0)||(year%4==0&&year%100!=0); } static FastReader in=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static class FastReader{ static BufferedReader br; static StringTokenizer st; FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next() { String str=""; while(st==null||!st.hasMoreElements()) { try { str=br.readLine(); }catch(IOException e) { throw new RuntimeException(e); } st=new StringTokenizer(str); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } } }
- 1
信息
- ID
- 13
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 47
- 已通过
- 30
- 上传者