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
#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