All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
abhi
Learning poster
Posts: 94 Joined: Fri Nov 25, 2005 7:29 pm
Post
by abhi » Tue Jun 19, 2007 7:52 pm
why WA ???
Last edited by
abhi on Wed Jun 20, 2007 4:41 am, edited 1 time in total.
Spykaj
New poster
Posts: 47 Joined: Sun May 21, 2006 12:13 pm
Post
by Spykaj » Tue Jun 19, 2007 8:03 pm
1
-5
Why unsigned ? Are you read this line: "If you cannot find a positive sequence, you should consider 0 as the value of the maximum product." ?
abhi
Learning poster
Posts: 94 Joined: Fri Nov 25, 2005 7:29 pm
Post
by abhi » Wed Jun 20, 2007 4:31 am
my program outputs the following for ur test case
Code: Select all
Case #1: The maximum product is 0.
abhi
Learning poster
Posts: 94 Joined: Fri Nov 25, 2005 7:29 pm
Post
by abhi » Wed Jun 20, 2007 4:41 am
never mind.
found my error and got AC
lnr
Experienced poster
Posts: 142 Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh
Post
by lnr » Wed Jul 04, 2007 10:08 am
Last edited by
lnr on Sat Sep 01, 2007 11:34 am, edited 4 times in total.
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Wed Jul 04, 2007 5:54 pm
Use 'long long' instead of 'long double'.
lnr
Experienced poster
Posts: 142 Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh
Post
by lnr » Sat Jul 14, 2007 6:06 pm
Last edited by
lnr on Sun Jul 15, 2007 6:20 pm, edited 1 time in total.
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Sat Jul 14, 2007 10:40 pm
Try the cases.
Input:
Code: Select all
16
-3 -2 3 4 8 8 -1 -1 7 -4 9 3 2 -5 10 -2
12
4 5 5 3 0 7 -3 0 10 2 4 -1
17
10 2 -10 2 10 5 -8 8 -6 -7 7 0 -5 -2 6 8 5
Output:
Code: Select all
Case #1: The maximum product is 348364800.
Case #2: The maximum product is 300.
Case #3: The maximum product is 376320000.
Hope these help.
lnr
Experienced poster
Posts: 142 Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh
Post
by lnr » Sun Jul 15, 2007 6:25 pm
Last edited by
lnr on Wed Aug 01, 2007 4:25 pm, edited 1 time in total.
andysoft
Experienced poster
Posts: 109 Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:
Post
by andysoft » Tue Jul 17, 2007 9:52 pm
What's must be the printf format? "%d", "%ld", "%lld" ???
My program is ok, if I look at my answer in Borland's c++ debugger, answer is ok, but when answer is too big (int64 size), values in debugger and printed in the console DIFFER. I guess it is because of output format.
andysoft
Experienced poster
Posts: 109 Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:
Post
by andysoft » Tue Jul 17, 2007 9:58 pm
this is my code. strange that even when I translated it to pas (where it prints int64's ok for sure) it gives WA. Maybe look what's wrong..
Code: Select all
#include <cstdlib>
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char* argv[]) {
int i,j,n,a[20],ci;
long long int b[20],max;
ci = 0;
while (cin >> n) {
ci++;
b[0] = 1;
for (i=1; i<=n; i++) {
cin >> a[i];
if (b[i-1] != 0)
b[i] = a[i]*b[i-1];
else
b[i] = a[i];
}
getchar ();
max = 0;
for (i=1; i<=n; i++)
for (j=i; j<=n; j++)
if (b[i-1] != 0)
if (b[j]/b[i-1] > max)
max = b[j]/b[i-1];
cout << "Case #" << ci << ": The maximum product is ";
printf ("%lld.\n\n",max);
}
return 0;
}
ayeshapakhi
Learning poster
Posts: 60 Joined: Sun Apr 16, 2006 7:59 pm
Post
by ayeshapakhi » Tue Jul 17, 2007 11:35 pm
hi...
fix this...
input.........
3
-1 0 -1
output.......
Case #1: The maximum product is 0.
>> but urs code outputs 1..
andysoft
Experienced poster
Posts: 109 Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:
Post
by andysoft » Wed Jul 18, 2007 12:23 pm
Thank you for the test case, ayeshapakhi !
I thought my prog is working fine with zeros and I was concentrating on other test cases, but all they passed.
Now I got AC @ 0.002s
dipaly
New poster
Posts: 20 Joined: Tue Sep 19, 2006 6:18 pm
Location: bangladesh
Contact:
Post
by dipaly » Thu Aug 30, 2007 6:31 pm
hi .........i get wa on this prob.. . i use O(n) algo..
can any one help me to find the mistake
sorry 4 submitting code
deleted
Last edited by
dipaly on Fri Aug 31, 2007 4:12 pm, edited 1 time in total.
everything is so hard to me
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Thu Aug 30, 2007 9:59 pm
Check your code again. You are using
Isn't it should be
Hope it helps.