| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Again!man, man , man!!! Why i Get WrongAnswer???
import java.io.*;
import java.util.*;
public class Main {
static int n = 0;
public static int Fecha(int Day,int Month, int Year)
{
int century,yr,dw;
int a,b,c,d,e;
if (Month < 3)
{
Month = Month + 10;
Year = Year - 1;
}
else
Month -= 2;
century = (int) Year / 100;
yr = (int) Year % 100;
dw = (((26 * Month -2) / 10) + Day + yr + (yr /4) + (century / 4) - (2 * century)) % 7;
if (dw < 0)
return (dw + 7);
else
return (dw);
}
public static boolean Leap(int Ano)
{
boolean Sw = (Ano % 400 == 0 || Ano % 100 != 0 && Ano % 4 == 0 );
return (Sw);
}
public static int Meses (int Vec[])
{
int c = 1;
if (n <= 31)
return (1);
else
while (n > Vec[c])
{
n -= Vec[c];
//System.out.println (Vec[c]);
c++;
}
return c;
}
public static int Anos()
{
int Ano = 2000;
if (n <= 366)
return 2000;
else
{
int MaxDia = 366;
while (n >= MaxDia)
{
if (Leap(Ano))
{
MaxDia = 366;
n -= MaxDia;
Ano++;
}
else
{
MaxDia = 365;
n -= MaxDia;
Ano++;
}
}
}
return Ano;
}
public static void main(String[] args)
{
try
{
int Ano = 2000;
int Vec[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
String DiaSem[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
// BufferedReader Leer = new BufferedReader (new FileReader (new File ("Hola.txt")));
BufferedReader Leer = new BufferedReader (new InputStreamReader (System.in));
n = Integer.parseInt (Leer.readLine());
n++;
while (n > 0)
{
int a = Anos ();
if (Leap(a))
Vec[2] = 29;
else
Vec[2] = 28;
int m = Meses (Vec);
String AuxDia = "", AuxMes = "";
if (n < 10 || m < 10)
{
if (n < 10)
AuxDia += "0" + Integer.toString(n);
else
AuxDia += Integer.toString(n);
if (m < 10)
AuxMes += "0" + Integer.toString(m);
else
AuxMes += Integer.toString(m);
System.out.print (a+"-"+AuxMes+"-"+AuxDia);
}
else
System.out.print (a+"-"+m+"-"+n);
int x = Fecha(n,m,a);
System.out.println (" "+DiaSem[x]);
n = Integer.parseInt (Leer.readLine());
n++;
}
}
catch (Exception e)
{
System.out.println ("Fuck"+e);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator