Page 2 of 3

10700 Why WA???

Posted: Sat Sep 25, 2004 5:46 pm
by Morning
[cpp]
#include <iostream>
using namespace std;
#define isNumber(c) (c >= '0' && c <= '9')

class Stack
{
public:
Stack();
void push(int n);
long long pop();
long long point;
long long data[32];
};
Stack::Stack()
{
point = 0;
}
void Stack::push(int n)
{
data[point++] = n;
}
long long Stack::pop()
{
return data[--point];
}

long long max(char str[128])
{
long long n = 0;
Stack *s = new Stack();
for (int i = 0;str != '\0';i++)
{
if (isNumber(str))
{
n = str - '0';
if (isNumber(str[i + 1]))
{
i++;
n = n * 10 + str - '0';
}
s->push(n);
}
else
{
if (str == '+')
{
i++;
n = str - '0';
if (isNumber(str[i + 1]))
{
i++;
n = n * 10 + str - '0';
}
n += s->pop();
s->push(n);
}
}
}
n = 1;
for (int j = 0;j < s->point;j++)
{
n *= s->data[j];
}
delete s;
return n;
}
int min(char str[128])
{
long long n = 0;
Stack *s = new Stack();
for (int i = 0;str != '\0';i++)
{
if (isNumber(str))
{
n = str - '0';
if (isNumber(str[i + 1]))
{
i++;
n = n * 10 + str[i] - '0';
}
s->push(n);
}
else
{
if (str[i] == '*')
{
i++;
n = str[i] - '0';
if (isNumber(str[i + 1]))
{
i++;
n = n * 10 + str[i] - '0';
}
n *= s->pop();
s->push(n);
}
}
}
n = 0;
for (int j = 0;j < s->point;j++)
{
n += s->data[j];
}
delete s;
return n;
}

int main()
{
int n;
char str[128] = "";
cin >> n;
cin.getline(str,128);
while(n--)
{
cin.getline(str,128);
cout << "The maximum and minimum are " << max(str) << " and " << min(str) << '.' << endl;
}
return 0;
}[/cpp]

Posted: Sat Sep 25, 2004 6:05 pm
by Junayeed
Try this i/p

20*20*20*20*20*20*20*20*20*20*20*20

Hope this will help

Posted: Sat Sep 25, 2004 7:05 pm
by Morning
yeah,stupid mistake
thanks so much,buddy:)

10700 test data

Posted: Thu Mar 17, 2005 3:17 pm
by phoenixKonquerer
Hello there, I got WA for question 00 for volume 107.

Is there anyone out there with AC to this problem and if yes can you please supply me with some testing input data along with the correct answer to it please.

Thank you so much. :lol:

Posted: Thu Mar 17, 2005 3:32 pm
by mf
My solution was simply to swap the priority of operators '+' and '*'. Perhaps you're getting WA if you don't use 64-bit integers

Consider this case:
20*20*20*20*20*20*20*20*20*20*20*20

Re: Camel Trading WA

Posted: Fri Mar 18, 2005 2:22 pm
by phoenixKonquerer
Hello I took ur advise and change my int variables to unsigned long long variables but I still got a WA for my submission.

The answer to ur example is

4096000000000000

Do u have any more testing data ?

Thanks for your help.

Posted: Wed Apr 06, 2005 12:41 am
by Dmytro Chernysh
Yep, indeed, the answers are
The maximum and minimum are 4096000000000000 and 4096000000000000.

Posted: Sat Jun 04, 2005 11:50 am
by emotional blind
Junayeed,
you told that your previous output was right

which was

input

Code: Select all

20*20*20*20 

output

Code: Select all

160000 and 0.
how the "0" comes for the minimum
i think Junayeed was wrong
can anyone explain[/quote]

Posted: Sat Jun 04, 2005 1:54 pm
by Mohammad Mahmudur Rahman
The output should be 160000 and 160000 according to my AC program.

Posted: Sat Jun 11, 2005 8:27 am
by emotional blind
thanks a lot

10700 - can't find mistake

Posted: Thu Oct 13, 2005 3:14 pm
by sunny
i don't know for what input my program fails to output correctly.
i considered the case where all 12 numbers are 20. any1 pls debug my code.


[ Code removed By Moderator ]

10700 sampl input-output??

Posted: Thu Nov 24, 2005 3:51 pm
by Tanu
plz give me some sample input-output for problem 10700
http://acm.uva.es/p/v107/10700.html
I don't forgot to use long long data type...
Thanks in advance...
Tan

i/o for 10700

Posted: Thu Nov 24, 2005 3:55 pm
by Rocky
what ouput does you get for this input
1
20*20*20*20*20*20*20*20*20*20*20*20

GOOD LUCK
Rocky

Thanks

Posted: Mon Nov 28, 2005 2:29 pm
by Tanu
Yah i got it accepted...
Thanx

Re: 10700 - can't find mistake

Posted: Sat Dec 10, 2005 11:17 pm
by Martin Macko
sunny wrote:printf("The maximum and minimum are %.0Lf and %.0Lf\n",max,min);
You forgot "." at the end of the output sentence.

In future, please, put your code to

Code: Select all

 tags.