// Codeforces Round #183 (Div. 2) B Calendar
import java.io.*;
import java.math.*;
import java.util.*;
//Codeforces
public class MainCodeforces2 {
private static MyScanner in;
private static PrintStream out;
private static boolean LOCAL_TEST = false;
private static void solve() throws IOException
{
String s1 = in.nextString();
String s2 = in.nextString();
String stemp;
if (s1.compareTo(s2) > 0) {
stemp = s1;
s1 = s2;
s2 = stemp;
}
String[] ss1 = s1.split(":");
String[] ss2 = s2.split(":");
int[] maxdate = new int[] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
31 };
int[] date1 = new int[3];
int[] date2 = new int[3];
for (int i = 0; i < 3; i++) {
date1[i] = Integer.valueOf(ss1[i]);
date2[i] = Integer.valueOf(ss2[i]);
}
int i = 0;
while (true) {
boolean equal = true;
for (int j = 0; j < 3; j++) {
if (date1[j] != date2[j])
equal = false;
}
if (equal)
break;
i++;
// inc date1
boolean leapyear = false;
if (date1[0] % 400 == 0)
leapyear = true;
else if (date1[0] % 100 == 0)
leapyear = false;
else if (date1[0] % 4 == 0)
leapyear = true;
int curMaxDate = maxdate[date1[1]];
if (date1[1] == 2 && leapyear)
curMaxDate = 29;
if (date1[2] == curMaxDate)
date1[2] = 1;
else
date1[2] += 1;
if (date1[2] == 1) {
if (date1[1] == 12)
date1[1] = 1;
else
date1[1] += 1;
if (date1[1] == 1)
date1[0]++;
}
}
out.println(i);
}
public static void main(String[] args) throws IOException {
// helpers for input/output
out = System.out;
try {
String cname = System.getenv("COMPUTERNAME");
LOCAL_TEST = (cname.equals("ALPHA530"));
} catch (Exception e) {
}
if (LOCAL_TEST) {
in = new MyScanner("E:\\zin.txt");
}
else {
boolean usingFileForIO = false;
if (usingFileForIO) {
// using input.txt and output.txt as I/O
in = new MyScanner("input.txt");
out = new PrintStream("output.txt");
}
else {
in = new MyScanner();
out = System.out;
}
}
solve();
}
// =====================================
static class MyScanner {
Scanner inp = null;
public MyScanner() throws IOException
{
inp = new Scanner(System.in);
}
public MyScanner(String inputFile) throws IOException {
inp = new Scanner(new FileInputStream(inputFile));
}
public int nextInt() throws IOException {
return inp.nextInt();
}
public long nextLong() throws IOException {
return inp.nextLong();
}
public double nextDouble() throws IOException {
return inp.nextDouble();
}
public String nextString() throws IOException {
return inp.next();
}
public String nextLine() throws IOException {
return inp.nextLine();
}
}
}
No comments:
Post a Comment