
11070 - The Good Old Times
Moderator: Board moderators
-
- New poster
- Posts: 12
- Joined: Wed Oct 13, 2004 10:14 am
- Location: Teh
- Contact:
11070 - The Good Old Times

Last edited by Ashkankhan on Sun Aug 13, 2006 6:06 am, edited 2 times in total.
-
- New poster
- Posts: 43
- Joined: Mon Oct 13, 2003 4:54 pm
- Location: Mexico
- Contact:
Re: 11079 : The Good Old Times
input:
100
-10+2+2
Correct output
100.000
-6.000
your output is
0.000
4.000
100
-10+2+2
Correct output
100.000
-6.000
your output is
0.000
4.000
-
- Experienced poster
- Posts: 111
- Joined: Mon Jan 09, 2006 6:19 pm
- Location: Tehran, Iran
- Contact:
during the contest i've got several CE on this problem , and when i checked my mail, it was written No Such a File or Directory but after contest i submit it without any changes and i got AC , can somebody tell me why this happens? because it was very awful during the contest
In being unlucky I have the record.
well if any one gets WA then u may try with these:
i was having trouble with multiple unary oparators
Code: Select all
--9
-1-1+9/3
---9
-9--+-9
Self judging is the best judging!
Oops

My output for this:
2*-0.5+-0.5*3+-15.5
1/2/2
-3.0
3
4.0+3.0/5.0
1*2*3+1+1*2+1*2*3*4
--9
-1-1+9/3
---9
-9--+-9
100
-10+2+2
is
-18.000
0.250
-3.000
3.000
4.600
33.000
9.000
1.000
-9.000
-18.000
100.000
-6.000
it this correct?
Please some one can help me?
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: Oops
Yes, it is.ivan.cu wrote:it this correct?
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: 11079 : The Good Old Times
Ashkankhan, could you, please, change the subject of this topic, so it would contain the number of this problem (i.e., 11070) instead of the number 11079? I think many people would appreciate it.
-
- System administrator & Problemsetter
- Posts: 399
- Joined: Sat Jan 12, 2002 2:00 am
hmm
"No input file" is a bug of the judge. So try submitting again and again if you get this error.
talking about the error, yesterday i faced a new thing, judge accepted code till 5:00:59. why so? i got last ac at 5:00:02. so today i checked the status page and i c that judge evaluated till 5:00:53
http://online-judge.uva.es/contest/stat ... =2128&r=60
http://online-judge.uva.es/contest/stat ... =2128&r=60
Self judging is the best judging!
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
How does the expresion '5*-2' make no sense? I don't understand.trulo17 wrote:i guess most of the input given here don't appear in judge's input, i got ac withouth considering such cases(in fact, i consider unary operators will appear only at th beginning of a line, after all expresions like 5*-2 doesn't make sense)

Here is my WA Code
Code: Select all
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
class Main {
public static void main(String[] args) {
// try {
// System.setIn(new FileInputStream("input.txt"));
// } catch (FileNotFoundException e1) {
// }
boolean end = false;
String n = "";
try {
n = Consola.readLine();
} catch (Exception e) {
end = true;
}
Main m = new Main();
while (!end) {
System.out.println(m.doIt(n));
try {
n = Consola.readLine();
} catch (Exception e) {
end = true;
}
}
}
private String doIt(String c) {
Expr t = new Expr(c);
return format("" + t.eval());
}
private String format(String a) {
String r = "";
int i = 0, l = a.length();
boolean decimal = false;
while (i < l) {
r += a.charAt(i);
if (a.charAt(i) == '.' || a.charAt(i) == ',') {
decimal = true;
if (i + 1 < l)
r += a.charAt(i + 1);
else
r += "0";
if (i + 2 < l)
r += a.charAt(i + 2);
else
r += "0";
if (i + 3 < l)
r += a.charAt(i + 3);
else
r += "0";
break;
}
i++;
}
if (!decimal)
r += ".000";
return r;
}
}
class Expr {
char o;
double v;
Expr r, d;
public double valueOf(String n) {
int l = n.length();
int i = 0;
int a = 0;
int d = 0;
int cd = 1;
boolean dc = false;
while (i < l) {
if (n.charAt(i) == '.') {
dc = true;
} else {
if (dc) {
a = a * 10 + (n.charAt(i) - '0');
cd *= 10;
} else {
d = d * 10 + (n.charAt(i) - '0');
}
}
i++;
}
if (dc)
return 1.0d * d + 1.0 * a / cd;
else
return 1.0d * d;
}
public Expr(String c) {
int i = c.length() - 1;
while (i >= 0 && c.charAt(i) != '+' && c.charAt(i) != '-') {
i--;
do {
i--;
} while (i >= 0
&& (c.charAt(i) == '+' || c.charAt(i) == '-'
|| c.charAt(i) == '*' || c.charAt(i) == '/'));
i++;
}
if (i > 0 && (c.charAt(i) == '+' || c.charAt(i) == '-')) {
o = c.charAt(i);
r = new Expr(c.substring(0, i));
d = new Expr(c.substring(i + 1));
} else {
i = c.length() - 1;
while (i >= 0 && c.charAt(i) != '*' && c.charAt(i) != '/')
i--;
if (i >= 0 && (c.charAt(i) == '*' || c.charAt(i) == '/')) {
o = c.charAt(i);
r = new Expr(c.substring(0, i));
d = new Expr(c.substring(i + 1));
} else {
o = 'v';
char in = c.charAt(0);
int p = 1;
while (in == '-' || in == '+') {
c = c.substring(1);
p *= in == '-' ? -1 : 1;
in = c.charAt(0);
}
v = p * Double.valueOf(c).doubleValue();
}
}
}
public double eval() {
switch (o) {
case 'v':
return v;
case '+':{
double aa = r.eval();
double bb = d.eval();
return aa + bb;
}
case '-':
return r.eval() - d.eval();
case '*':
return r.eval() * d.eval();
case '/':
return r.eval() / d.eval();
}
return -1;
}
}
class Consola {
private static int maxLongitud = 256;
private static byte[] lin = new byte[maxLongitud];
public static String readLine() throws Exception {
int lg = 0, car = -1;
try {
while (true) {
car = System.in.read();
if ((car < 0 && lg == 0)
|| ((car < 0) || (car == '\r') || (car == '\n'))
&& lg != 0) {
break;
} else if (!((car < 0) || (car == '\r') || (car == '\n'))) {
lin[lg++] = (byte) car;
}
}
} catch (Exception e) {
throw (null);
}
if ((car < 0) && (lg == 0))
throw (null); // eof
return (new String(lin, 0, lg));
}
public static String readWord() throws Exception {
int lg = 0, car = -1;
try {
while (true) {
car = System.in.read();
if ((car < 0 && lg == 0) || (car <= 32 && lg != 0)) {
break;
} else if (!(car <= 32)) {
lin[lg++] = (byte) car;
}
}
} catch (Exception e) {
throw null;
}
if ((car < 0) && (lg == 0)) {
throw null; // eof
}
lin[lg] = '\0';
return (new String(lin, 0, lg));
}
public static int readInt() throws Exception {
String read = readWord();
if (read.equals(null)) {
throw null;
}
return Integer.parseInt(read);
}
}
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: Here is my WA Code
Try:ivan.cu wrote:Code: Select all
//import java.io.FileInputStream; //import java.io.FileNotFoundException; ...
Code: Select all
-10*0
Code: Select all
0.000
Code: Select all
-0.000