← Back to topics
Topic

task :: z-javelin

F
FilipKeri
Can someone tell me why this code isn't working:

#include <cstdio>
#include <iostream>

bool prov [ 10000000 ] ;
long int x, y, i, j, sol = 0, broj, a, b, n ;

int main () {
scanf("%lld", &n ) ;
memset( prov, true, sizeof( prov ) ) ;

for (long int i = 0 ; i < n ; ++i) {
scanf("%lld%lld%lld", &broj, &a, &b ) ;

for (long int j = 0; j <= a; ++j) {
if ( prov [ ( broj + ( j*b ) ) ] ) {
++sol ;
prov [ ( broj + ( j*b ) ) ] = false ;
}
}

}

printf("%lld\n", sol ) ;
system("pause");
return 0 ;
}

On every test case I'm getting WA, but the sample test is OK

thanks in advance
D
Dgleich
Well you don't need Long long for sure, int will work and i don't see any other error :)
F
FilipKeri
thx to Dgleich, any other opinion, 'cause I can't find my error
m
matteo123
I think
for (long int j = 0; j <= a; ++j) { 

must be
for (long int j = 0; j < a; ++j) { 


m
matteo123
you don't need cstdio.you need just iostream
maybe this is wrong
memset( prov, true, sizeof( prov ) ) ; 
D
Dgleich
change them to true when you visit one of them , it's easier that way...